Image encoding apparatus and control method thereof

ABSTRACT

A lossless encoding processing unit lossless-encodes respective tiles, and stores the encoded data in a memory. A determination unit determines, according to attribute information of each tile, whether the tile of interest is to be lossless- or lossy-encoded, and appends the determination result at the head of lossless-encoded data as a flag. The determination unit counts, in variable CH, the number of tiles determined to be lossy-encoded, during the lossless encoding processing. Every time the CH exceeds one of a plurality of different thresholds, a lossy encoding processing unit decodes lossless-encoded data appended with a lossy flag, applies processing for decreasing the resolution to the decoded data, lossless-encodes the data that has undergone the processing again, and stores the lossless-encoded data in the memory. Upon completion of the lossless encoding processing for one page, the lossy encoding processing unit lossy-encodes the lossless-encoded data appended with the lossy flag.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to a technique for lossless- or lossy-encoding image data for respective tiles.

2. Description of the Related Art

Upon categorizing image data based on the criteria of resolution and tone characteristics, they are roughly categorized into text (character)-based images which place importance on a high resolution, a natural image-based image which places an importance on tone expression, and graphics-based images which place an importance on the balance between both criteria.

As will be described below, suitable encoding methods differ depending on the types (or attributes) of image data.

A text-based image is normally formed of two types of pixels from a local viewpoint even when image data is input as multi level data. For this reason, the text-based image is suited to lossless encoding compared to other types of images.

Put differently, since the image entropy is low, the text-based image is suited to lossless encoding. However, since the entropy is low, a slight deterioration often visually stands out. Therefore, a high-quality text-based image is required to be lossless-encoded.

By contrast, a natural image-based image normally has high entropy (although it largely differs depending on objects). For this reason, if the natural image-based image is lossless-encoded, not so high compression ratio is expected. By applying encoding that allows deterioration of a visually inconspicuous part to the image of this type, a high compression ratio can be achieved. Such encoding is called lossy encoding as contrasted to the lossless encoding.

Therefore, a device which is required to attain high image quality adopts a method of compressing text-based image data by lossless encoding and natural image-based image data by lossy encoding.

On the frequency axis, deterioration in a higher-frequency range is hard to stand out compared to that in a lower-frequency range. In lossy encoding, it is a common practice to transform image data on a real space into frequency space data. As typical transformation, discrete cosine transformation (DCT) is known. Quantization processing required to reduce entropy is applied to the data transformed onto the frequency space. In this case, a quantization table has frequency dependence so that deterioration is suppressed as much as possible in the lower-frequency range, and it readily appears in the higher-frequency range. Finally, the quantized values undergo entropy-encoding using Huffman codes or the like.

Random noise is inevitably superposed on natural image data since the natural image data is generated by A/D-converting a signal photoelectrically converted by an image sensor. Such random noise-superposed data is very ill-suited to lossless encoding.

By contrast, a computer graphics-based image (to be referred to as a CG image hereinafter) is basically free from any random noise, and is suited to lossless encoding in this respect. Meanwhile, a CG image includes sharp edges which are not included in a natural image, and is unsuited to the DCT transformation.

The types of CG images are infinite in variety, i.e., there are many types of CG images from those with a fewer number of tone levels to those with a larger number of tone levels. Since a CG image approximate to a natural image can be generated, it cannot be categorically described that CG images are always suited to lossless encoding. Therefore, images include those suited to lossless encoding, and those suited to lossy encoding.

Since the aforementioned discrete cosine transformation is arithmetic processing including multiplications of real number coefficients, many processes are required (e.g., quantized values must be re-arranged to a predetermined order before entropy encoding, and so forth) in addition to simple integer operations. For this reason, a lossy encoder often requires a larger hardware scale.

By contrast, lossless encoding does not require any real number operations, and can carry out processing using only integer values to the end. Also, lossless encoding does not require any re-arrangement of data as long as transformation onto the frequency space is not made, and the hardware scale can be simplified.

In recent years, in order to attain higher image quality of output devices such as printers and the like, output devices tend to have higher resolutions. Image data tend to have higher resolutions accordingly, and the resolution of an image which previously had been 600 dpi tends to rise up to 1200 dpi and to 2400 dpi.

This means that the capabilities required of software and hardware used to encode and decode image data rise to 4 times and 16 times.

A technique for lossless- or lossy-encoding image data in predetermined units such as blocks or tiles is known (for example, Japanese Patent Laid-Open No. 09-149260).

An overview of this technique can be expressed by an arrangement shown in FIG. 4. In the arrangement shown in FIG. 4, image data 401 scanned from an image scanner or generated by rendering page description language data is divided into tiles. A lossless encoding unit 403 and lossy encoding unit 405 parallelly apply encoding processing to one tile. A determination unit 407 determines based on code sizes generated by the respective encoding units and various parameters obtained during the encoding processes whether or not the image data is to be lossless- or lossy-encoded, and sends the determination result to a selection unit 409.

The selection unit 409 selects one of the two different types of encoded data output from the two encoding units based on the determination result, and stores the selected encoded image data in a memory 411. In this way, encoding of one tile is completed. Upon completion of encoding of all tile data for one page image, the encoded data of the page image are transferred to and stored in a hard disk drive 413 together.

The memory 411 is a so-called semiconductor memory, and can only hold encoded data for several to several tens of pages. On the other hand, since the hard disk drive 413 generally has a capacity of several hundred Gbytes nowadays, it can store encoded data for several tens of thousands of pages or more.

Also, an arrangement shown in FIG. 5 can be easily considered. In this arrangement, a determination unit 421 has a function of directly generating parameters required to determine lossless or lossy encoding from tile data. This determination unit 421 determines, based on the generated parameters, which encoded data is to be selected. The determination result is sent to a distribution unit 423, which supplies tile data to one of the lossless encoding unit 403 and lossy encoding unit 405, and controls the selected encoding unit to encode the tile data. As a result, since one of the two encoding units outputs encoded data, encoding of that tile data is completed when that encoded data is stored in the memory 411.

In either of the arrangements shown in FIGS. 4 and 5, in order to encode arbitrary image data within a predetermined period of time (to be referred to as “one page time period” hereinafter), each of the two encoding units must have capability to encode all image data within one page time period.

Assuming that one encoding unit is used at a capacity usage ratio of 85% or more to encode all image data with a resolution of 600 dpi within one page time period, image data with a resolution of 1200 dpi has a fourfold data size. For this reason, encoding must be done by parallelly operating the four encoding units. Furthermore, since an image with a resolution of 2400 dpi has a 16-fold data size, its encoding process cannot be completed within one page time period unless 14 to 16 encoding units are parallelly operated.

As described above, conventionally, encoding must be done by parallelly operating many encoding units to encode image data with higher resolutions in large quantities, resulting in a huge circuit scale of the encoding units. Therefore, high cost is required to manufacture that encoding apparatus.

In order to reduce the hardware scale, the degree of parallelism of lossy encoding units to be parallelly operated is lowered. However, when the degree of parallelism is lowered, the capability of each lossy encoding unit drops, and the lossy encoding processing cannot be completed within a predetermined period of time, thus posing another problem.

SUMMARY OF THE INVENTION

The present invention provides a technique that can solve the conventional problems mentioned above.

To solve the above problems, an image encoding apparatus provided by the present invention comprises, e.g., the following arrangement. That is, there is provided an image encoding apparatus for encoding image data, comprising:

a lossless encoding processing unit adapted to lossless-encode the image data for respective tiles each having a pre-set size;

a determination unit adapted to determine for each tile based on an attribute of image data in the tile of interest if the tile of interest is to be lossless-encoded or lossy-encoded, and to generate lossless/lossy determination information;

a storage unit adapted to temporarily store the lossless-encoded data of the tile generated by the lossless encoding processing unit and the lossless/lossy determination information of the determination unit in association with each other;

a lossy encoding processing unit adapted to decode the lossless-encoded data having lossy determination information in the encoded data stored in the storage unit and to lossy-encode the decoded data;

an output unit adapted to output the lossy-encoded data generated by the lossy encoding processing unit and the lossless-encoded data having lossless determination information as an encoded result of the image data to be encoded; and

a control unit adapted to control the lossless encoding processing unit and the lossy encoding processing unit,

wherein the lossy encoding processing unit comprises:

a decoding unit adapted to decode the lossless-encoded data;

a lossy encoding unit adapted to lossy-encode the decoded image data;

a resolution converting unit adapted to convert the decoded image data into image data having a resolution lower than a resolution of the decoded image data; and

a lossless encoding unit adapted to lossless-encode the image data converted by the resolution converting unit,

wherein the control unit comprises:

a first replacing unit adapted to control the decoding unit, the resolution converting unit, and the lossless encoding unit to replace the lossless-encoded data having the lossy determination information stored in the storage unit by lossless-encoded data of a lower resolution, every time the number of tiles, which is determined by the determination unit to be lossy-encoded, exceeds one of a plurality of different thresholds; and

a second replacing unit adapted to control the decoding unit and the lossy encoding unit to replace the lossless-encoded data having the lossy determination information stored in the storage unit by lossy-encoded data upon completion of lossless encoding for one page by the lossless encoding processing unit.

According to the present invention, by appropriately setting a threshold associated with the number of tiles, lossy encoding processing capability is fully used, while encoded data including lossless- and lossy-encoded data together can be generated within a unit time period.

Other features and advantages of the present invention will be apparent from the following description taken in conjunction with the accompanying drawings, in which like reference characters designate the same or similar parts throughout the figures thereof.

BRIEF DESCRIPTION OF THE DRAWINGS

The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the invention and, together with the description, serve to explain the principles of the invention.

FIG. 1 is a block diagram of an image encoding apparatus according to the first embodiment;

FIG. 2 is a block diagram of an image encoding apparatus according to the second embodiment;

FIG. 3 is a block diagram of an image encoding apparatus according to the third embodiment;

FIG. 4 is a block diagram showing an example of the arrangement of a conventional image processing apparatus;

FIG. 5 is a block diagram showing another example of the arrangement of a conventional image processing apparatus;

FIG. 6 is a timing chart of encoding processing in one embodiment;

FIGS. 7A and 7B show examples of layouts of regions which are determined to undergo lossy encoding;

FIG. 8 shows a state of an increase/decrease in non-encoded data and an increase in lossy-encoded data without resolution conversion;

FIGS. 9A to 9D show an increase/decrease in non-encoded data of respective resolutions as a result of resolution conversion (once);

FIGS. 10A to 10C show an increase/decrease in non-encoded data of respective resolutions as a result of resolution conversion (twice);

FIG. 11 shows lossless-encoded data sizes of a plurality of resolutions for two different types of images;

FIG. 12 shows a code size obtained by adding a lossy code size as a predicted value or actually measured value to a lossless code size;

FIG. 13 shows lossless-encoded data sizes of a plurality of resolutions according to the third embodiment;

FIG. 14 is a block diagram of an image encoding apparatus according to the fourth embodiment;

FIG. 15 shows transition of increases in non-encoded data size of respective resolutions on a memory;

FIG. 16 is a block diagram of an apparatus for decoding encoded data obtained by the first embodiment;

FIG. 17 is a block diagram of an apparatus for decoding encoded data obtained by the second to fourth embodiments;

FIG. 18 is a timing chart of decoding processing;

FIG. 19 is a flowchart for explaining the processing sequence of a lossless encoding phase in the first embodiment;

FIG. 20 is a flowchart for explaining the processing sequence of the lossless encoding phase in the first embodiment;

FIG. 21 is a flowchart for explaining the processing sequence of the lossless encoding phase in the first embodiment;

FIG. 22 is a flowchart for explaining the processing sequence of a lossy encoding phase in the first embodiment;

FIG. 23 is a block diagram of an image encoding apparatus in the fifth embodiment;

FIG. 24 is a block diagram of an image encoding apparatus in the sixth embodiment;

FIG. 25 is a block diagram of an image encoding apparatus in the seventh embodiment;

FIG. 26 is a flowchart for explaining the processing sequence of a lossless encoding phase in the fifth embodiment;

FIG. 27 is a flowchart for explaining the processing sequence of a lossy encoding phase in the fifth embodiment;

FIG. 28 is a graph showing an example of transition of a counter CH in the sixth embodiment;

FIG. 29 is a flowchart for explaining the processing sequence of a lossless encoding phase in the sixth embodiment;

FIG. 30 is a flowchart for explaining the processing sequence of a lossy encoding phase in the sixth embodiment;

FIG. 31 is a flowchart for explaining the processing sequence of a lossless encoding phase in the seventh embodiment; and

FIG. 32 is a flowchart for explaining the processing sequence of a lossy encoding phase in the seventh embodiment.

DESCRIPTION OF THE EMBODIMENTS

Preferred embodiments of the present invention will be describe in detail hereinafter with reference to the accompanying drawings.

First Embodiment

FIG. 1 shows the first basic arrangement required to implement encoding processing as a characteristic feature of this embodiment, and its operation will be explained using FIGS. 6 to 10C.

The arrangement of an image processing apparatus 100 shown in FIG. 1 will be briefly described first.

The image processing apparatus 100 shown in FIG. 1 is roughly separated into a lossless encoding processing unit 170 and a lossy encoding processing unit 180. The image processing apparatus 100 receives image data 401 generated by, e.g., an image scanner or page description language data rendering unit, and a lossless encoding unit 101 encodes the input image data. Assume that the resolution of the image data 401 is 2400 dpi.

Note that this embodiment uses a JPEG-LS encoding scheme known as one example of lossless encoding. Please refer to [International Standard Document: ISO/IEC IS 14495-1, “Information technology—Lossless and near-lossless compression of continuous-tone still images: Baseline”] for details of this technique.

To state briefly, the JPEG-LS encoding scheme executes lossless encoding of multi-valued pixels in a raster scan order using a nonlinear adaptive filter and context-based entropy encoding.

In order to obtain the context of each pixel to be encoded, a predetermined arithmetic operation is made with reference to surrounding pixels of the pixel of interest. At this time, by slightly adding processes, image attribute information including the number of colors, the degree of change, and the histogram of pixel values of surrounding pixels can be obtained.

A control unit 150 controls respective building units shown in FIG. 1, and includes a determination unit 103 to be described later.

The image data 401 is divided into tiles each having a size of, e.g., 32×32 pixels, and these tile data are input. Such image data having a size of 32×32 pixels will be merely referred to as tile data hereinafter. The lossless encoding unit 101 lossless-encodes the input tile data to generate lossless encoded data, and outputs the lossless encoded data to a selection unit 109. Also, the lossless encoding unit 101 obtains the aforementioned image attribute information for each tile, and outputs it to the determination unit 103. The determination unit 103 determines based on this image attribute information whether the tile data of interest is to be finally lossless-encoded or lossy-encoded.

The tile data to be lossless-encoded is also sent to a buffer 105, and is stored as non-encoded data (non-compressed data) in that buffer. The buffer 105 keeps holding the non-encoded data until the determination unit 103 outputs the determination result.

The determination result output from the determination unit 103 is sent to the selection unit 109. If this determination result indicates “lossless”, the selection unit 109 selects the encoded data output from the lossless encoding unit 101; if the determination result indicates “lossy”, the selection unit 109 selects the non-encoded data saved in the buffer 105 and stores it in a memory 111. At this time, the selection unit 109 appends 1-bit identification data indicating lossless-encoded data or non-encoded data to the head of the data to be stored in the memory 111.

The aforementioned processes collectively mean <lossless encoding processing>. In this embodiment, this <lossless encoding processing> is completed within one page time period. Then, <lossy encoding processing> to be described later is executed within the next one page time period. The timing relationship between <lossless encoding processing> and <lossy encoding processing> will be described below using FIG. 6. Note that one page time period is determined depending on the total number of pixels of an image to be input. When a document image is to be scanned, the total number of pixels is determined based on the document size and the scan resolution.

Both <lossless encoding processing> and <lossy encoding processing> execute encoding required for image data for one page within one page time period. As will be described later, encoding processes are not simultaneously applied to the same page. More specifically, as shown in FIG. 6, a page image that has undergone <lossless encoding processing> then undergoes <lossy encoding processing> in the next page time period. The encoded data of the image which has undergone <lossy encoding processing> is finally transferred from the memory 111 to a storage device such as a hard disk drive or the like.

Paying attention to only an image of a given page, two page time periods are required to apply the lossless and lossy encoding processes. However, as a throughput (processing capability) upon encoding images for a plurality of pages, since the processes are done in a pipeline manner, as shown in FIG. 6, the encoding processing of an image for one page can be substantially completed within one page time period.

In <lossy encoding processing>, a lossy encoding unit 115 lossy-encodes the non-encoded data (which can be determined based on the bit in the head of each data) in the memory 111 within one page time period to convert it into lossy encoded data.

This embodiment uses a known JPEG encoding scheme as an example of lossy encoding, which orthogonally transforms image data corresponding to 8×8 pixels, quantizes transformation coefficients, and then applies Huffman encoding processing to the quantized values.

Since the object of the present invention is to reduce cost by reducing the circuit scale of the lossy encoding unit 115, this lossy encoding unit 115 need not have capability to encode all image data for one page within one page time period. That is, assume that the lossy encoding unit 115 is only capable of encoding N % of all the image data.

This capability is not determined first but is determined depending on the specification of the image processing apparatus of this embodiment, the processing capability of a lossy encoder alone, and the number of encoders to be parallelly operated. However, this embodiment assumes a capability within the range of N=( 1/16 to 1/14)×100% in consideration of the resolution of image data to be encoded and the input rate of each page.

The determination unit 103 determines whether the tile of interest is to be lossy-encoded or lossless-encoded, and counts the number of input tiles and the number of tiles to be lossy-encoded. Note that the ratio of the number of tiles to be lossy-encoded to the total number of tiles of one page of image data (to be referred to as a “lossy-encoding ratio” hereinafter) exceeds N %. In this case, the lossy encoding processing of the non-encoded data in the memory 111 cannot be completed within one page time period.

In order to solve this problem, the image processing apparatus of this embodiment recursively applies resolution conversion to the non-encoded data to reduce a data size, so that the data to be lossy-encoded becomes N % or less.

Whether or not to apply resolution conversion and the number of stages to be applied upon application of resolution conversion are controlled based on the lossy encoding ratio. How the flow of the resolution conversion processing changes depending on the lossy encoding ratio will be explained below. <When lossy encoding ratio≦N (%)>

As described above, upon outputting the determination result (also called a selection signal) to the selection unit 109, the determination unit 103 counts the number of tiles determined as “lossy”. The total number of tiles of an image for one page depends on the number of pixels of input image data. Therefore, the lossy encoding ratio upon completion of the lossless encoding processing for one page can be calculated as the ratio of the number of tiles determined as “lossy” to the total number of tiles. The processing executed <when lossy encoding ratio≦N (%)> to be described below is also processing to be executed when the lossy encoding ratio does not exceed N % till completion of the lossless encoding processing for an image of one page.

The following description will be done in order to avoid misunderstanding. The lossy encoding unit 115 adopts JPEG encoding in this embodiment, and the minimum encoding size is an 8×8 pixel size. Since the size of one tile is 32×32 pixels, 16 blocks each having a size of 8×8 pixels are included in each tile. Therefore, upon conversion by the block having an 8×8 pixel size in the lossy encoding unit 115, the capability value N is 16 times the number of tiles determined to be lossy-encoded.

If the ratio of tiles to be lossy-encoded determined by the determination unit 103 is N % or less, since the ratio of the corresponding non-encoded data also becomes N % or less, the lossy encoding processing can be completed within one page time period without any resolution conversion. Independency of a region to be lossy-encoded on the location within a page as long as the ratio is N % or less will be explained below using FIGS. 7A, 7B, and 8.

Of two page images shown in FIGS. 7A and 7B, a region to be determined as that to be lossy-encoded exists N % on the upper right portion of that page on an image with page number “1” shown in FIG. 7A. In this case, the memory 111 begins to store non-encoded data in an early stage within one page time period, as indicated by the upper row of FIG. 8, and stores the non-encoded data at a ratio of N %.

The lossy encoding unit 115 lossy-encodes the stored non-encoded data fully using the next page time period and converts them into lossy-encoded data. The lower row of FIG. 8 shows the way a non-encoded data size decreases and the way an encoded data size increases.

In this way, after an elapse of two page time periods, all the image data of the page to be encoded are encoded, and are converted into lossy-encoded data or lossless-encoded data that have already been encoded one page time period before.

On an image with page number “2” as the second example shown in FIG. 7B, a region to be determined as that to be lossy-encoded exists nearly N % on the lower right part of the page. In this case, the memory 111 begins to store non-encoded data in a latter stage within one page time period, as indicated by the upper column of FIG. 8, and stores the non-encoded data at a ratio of nearly N %.

Independently of the location of the region to be determined as that to be lossy-encoded on a page, the start time of the lossy encoding processing in the next page time period remains the same, but the end time of the lossy encoding processing varies depending on the ratio of the lossy-encoded data size. The two examples shown in the lower column of FIG. 8 show such difference. Since the image with page number “2” shown in FIG. 7B has a ratio slightly lower than N %, its lossy encoding processing is completed earlier accordingly, and the lossy-encoded data size remains constant without increasing from that timing. The same as in the example of page number “1” applies except for the above description. <When N(%)<lossy encoding ratio≦4×N(%)>

This processing is executed when the lossy encoding ratio exceeds N % during the lossless encoding processing of an image for one page, i.e., before completion of the lossless encoding processing of the image for one page.

If the lossy encoding ratio exceeds N % (at this time, the lossy encoding ratio is 4×N % or less obviously), the control unit 150 controls resolution converting units 107 and 113 to execute resolution conversion for halving the horizontal and vertical resolutions of non-compressed image data once. As a result, the non-encoded data size can be reduced to ¼. That is, the lossy encoding processing can be done within one page time period. Note that the resolution conversion generates one pixel after conversion from original 2×2 pixels. As an example of this resolution conversion, the value of a pixel at the predetermined position of the original 2×2 pixels is used as one pixel after conversion. Alternatively, the average value of the original 2×2 pixels may be used as the value of a pixel after conversion.

The resolution conversion processing will be described below using the block diagram of the image processing apparatus shown in FIG. 1 and the graphs showing the data sizes of respective resolutions shown in FIGS. 9A to 9D.

While the lossy encoding ratio is N % or less, the image processing apparatus operates, as has been described above. However, when it is detected that the lossy encoding ratio exceeds N % at timing T1 in FIG. 9A, the resolution converting unit halves the numbers of pixels in the horizontal and vertical directions of the non-encoded data with the resolution of 2400 dpi in the memory 111. That is, the resolution is reduced to 1200 dpi. The control unit 150 requests the resolution converting unit 113 for this processing to start the resolution conversion processing.

Upon starting the resolution conversion processing, since 2400-dpi non-encoded data that have already undergone the resolution conversion processing in the memory 111 become unnecessary, they are sequentially discarded. At the same time, non-encoded data after resolution conversion are sequentially stored in the memory 111. That is, the data size of the non-encoded data with the resolution of 2400 dpi decreases as time elapses, and the data size of non-encoded data with the resolution of 1200 dpi increases as time elapses.

Timing T2 in FIG. 9B indicates the end of the resolution conversion processing. That is, all the non-encoded data with the resolution of 2400 dpi are discarded, and 1200-dpi non-encoded data having the data size ¼ that of the 2400-dpi non-encoded data are stored in the memory 111.

The resolution converting unit 107 halves the horizontal and vertical resolutions of tile data of an image newly input at timing T1 via the buffer 105. When a tile is determined as that to be lossy-encoded, the data after resolution conversion stored in the buffer 105 is stored in the memory 111 from the selection unit 109, as shown in FIG. 9C. In this manner, the non-encoded data on the memory 111 are stored at a resolution of 1200 dpi, as shown in FIG. 9D, so that the data size can fall within the range that allows the lossy encoding processing within one page time period. <When 4N (%)<lossy encoding ratio≦16N (%)>

This processing is executed when the lossy encoding ratio exceeds 4×N % during the lossless encoding processing of an image for one page, i.e., before completion of the lossless encoding processing of the image for one page.

When the lossy encoding ratio exceeds 4×N % (when the lossy encoding ratio is 16×N % or less obviously), the control unit 150 controls the resolution converting unit 113 to execute resolution conversion again. It should be noted that the horizontal and vertical resolutions of non-encoded data stored in the memory 111 become ½ the original resolutions. Therefore, upon applying the resolution conversion by the resolution converting unit 113 again, the resolutions of the non-encoded data in the memory 111 become ¼ the original resolutions.

On the other hand, the control unit 150 instructs the resolution converting unit 107 to reduce the horizontal and vertical resolutions of input tile data to ¼, so as to execute resolution conversion of the tile data in the buffer 105. As a result, the resolution converting unit 107 reduces the horizontal and vertical resolutions of the newly input image data to ¼ (600 dpi) via the buffer 105. As a tile determined as that to be lossy-encoded, 600-dpi data that has undergone the resolution conversion is stored in the memory 111. In this way, the non-encoded data size is reduced to 1/16 to allow the lossy encoding processing within one page time period.

FIG. 10A shows an increase/decrease in 2400-dpi non-encoded data size on the memory 111, and FIG. 10B shows an increase/decrease in 1200-dpi non-encoded data size on the memory. The 1200-dpi data size begins to decrease at the start timing of the second resolution conversion processing. FIG. 10C shows 600-dpi non-encoded data stored in the memory 111. The non-encoded data are generated by the second resolution conversion processing and applying resolution conversion to input image data.

Since this embodiment assumes the range of N=( 1/16 to 1/14)×100%, examples in which the lossy encoding ratio exceeds 16N % are not shown. However, as can be easily understood from the above description, if the lossy encoding ratio exceeds 16N %, the third resolution conversion can be executed, and if it exceeds 64N %, the fourth resolution conversion can be executed.

In the above embodiment, the first resolution conversion halves the horizontal and vertical resolutions to reduce the non-encoded data size to ¼. Alternatively, the first resolution conversion may halve either of the horizontal and vertical resolutions, and the second resolution conversion may halve the other resolution. In this case, the data size can be reduced to ½ by the first resolution conversion, and the non-encoded data size can be controlled more flexibly. In this case, the timings at which the lossy encoding ratio exceeds N, 2N, 4N, 8N, and 16N must be detected.

A detailed processing sequence (that of the control unit 150) of the encoding processing in the above embodiment will be described below using FIGS. 19 to 22. Assuming that the user can arbitrarily set the tile size under predetermined conditions, an extended translation of the above embodiment will be given. In the above embodiment, the lossy encoding unit 115 adopts JPEG encoding as its lossy encoding. Therefore, the tile size is an integer multiple of an 8×8 pixel size. However, for the sake of simplicity, assume that an input original tile size has 8×2^(i) pixels in both the horizontal and vertical directions. Also, in the following description, some variables will appear, and they will be explained at the time of their appearance.

In step S1, the user determines a tile size. The tile size has 8×2^(i) pixels in both the horizontal and vertical directions. The user sets this variable i via an operation panel or the like (not shown). Note that i=2 in the aforementioned example.

The process advances to step S2 to substitute “1” in variable P used manage a page number so as to start encoding of the first page.

The process advances to step S3 to determine the total number Tmax of tiles based on the numbers of pixels in the horizontal and vertical directions of image data to be encoded and the determined tile size. When a document image is scanned, the size of image data can be determined based on the document size and the scan resolution (2400 dpi in this embodiment). Since an arrangement for detecting the original size is known to those who are skilled in the art, a description thereof will be omitted.

The process then advances to step S4 to determine thresholds Th( ) used to detect the resolution conversion timings. The total number Tmax of tiles is determined depending on variable i upon determining the tile size, and respective thresholds are determined based on this total number of tiles. Th(0)←(N/100)×Tmax Th(1)←(N/100)×4×Tmax Th(2)←(N/100)×16×Tmax where N is the encoding capability value of the lossy encoding unit 115 for all image data, as described above. The number of thresholds Th( ) is limited by variable i since the lossy encoding unit 115 requires at least a size of 8×8 pixels in this embodiment.

The process advances to step S5 to initialize variables Tc, Ch, and Rr.

Variable Tc is used to manage the number of a tile of interest, and its initial value is “1”. Variable Ch is used to manage the number of tiles determined as “lossy”, and its initial value is “0”. Variable Er is used to manage the target resolution of the resolution converting unit 107, and its initial value is “1”. The resolution converting unit 107 executes processing for reducing the tile size in the buffer 105 to 1/Rr in both the horizontal and vertical directions. Since the other resolution converting unit 113 always executes resolution conversion to ½, no variables are required to manage it. Variable K stores a value indicating the number of times of execution of the resolution conversion. The initial value of variable K is “0”, and is also used as a variable for specifying one of the thresholds Th( ) to be described later.

With the above processes, the initialization processing for encoding of one page is completed. Then, encoding processing is executed in step S6 and subsequent steps.

It is checked in step S6 if variable P is larger than 2, i.e., if an image whose lossless encoding is about to start is the third or subsequent page.

As described above using FIG. 6, upon starting lossless encoding for the third or subsequent page, the lossy encoding unit 115 must complete lossy encoding processing for an image two pages before. This checking processing is done in step S7. If it is determined that lossy encoding two pages before is not complete yet, the process advances to step S8 to execute error processing.

If NO in step S6 or if YES in step S7, the process advances to step S9.

In step S9, the Tc-th tile data of the image data to be encoded is input. In step S10, the input tile data is stored in the buffer 105.

It is checked in step S11 if variable Rr=“1”. If Rr=1, since the need for the conversion processing of the resolution converting unit 107 can be obviated, the process jumps to step S13. On the other hand, if variable Rr≠“1”, the process advances to step S12 to set 1/Rr in the resolution converting unit 107 and to control it to execute resolution conversion. The resolution conversion result by the resolution converting unit 107 is re-stored (overwritten) on the buffer 105.

In steps S13 and S14, the lossless encoding unit 101 executes lossless encoding processing of the tile data of interest, and calculates attribute information of that tile of interest.

It is checked in step S15 based on the calculated attribute information if lossless-encoded data of the tile of interest is adopted.

As described above, the attribute information is calculated from the number of colors, degree of change, histogram of pixel values, and the like of surrounding pixels with reference to the surrounding pixels upon lossless-encoding a pixel of interest in the lossless encoding processing.

A practical example of calculation of the attribute information will be described below.

As described above, the lossless encoding unit 101 adopts JPEG-LS, and the lossy encoding unit 115 adopts JPEG. Both these methods are entitled with “JPEG”, but their encoding algorithms are quite different. These encoding processes themselves are known to those who are skilled in the art, but “JPEG” is encoding suited to natural images (especially, landscapes, portraits, and the like), and JPEG-LS is encoding suited to text and line images. Using these features, the attribute information may be calculated to allow to select lossless encoding for text/line images easily and to select lossy encoding for natural images easily.

The attribute information to be calculated may include:

the number of colors that appear in a tile;

the number of times of determination indicating that the density (or luminance) difference between two neighboring pixels in a tile is equal to or larger than a predetermined threshold;

the median or variance of a histogram generated to have the density (or luminance) difference between two neighboring pixels in a tile as the horizontal axis;

the generated lossless-encoded data length, etc.

The lossless-encoded data is adopted when the following conditions are met:

1. the number of colors that appear in a tile is equal to or smaller than a given threshold,

2. the number of times of determination indicating that the density (or luminance) difference between two neighboring pixels in a tile is equal to or larger than a predetermined threshold is equal to or larger than a given threshold,

3. the median of a histogram generated to have the density (or luminance) difference between two neighboring pixels in a tile as the horizontal axis is equal to or larger than a given threshold and the variance of that histogram is equal to or smaller than a given threshold, and

4. the generated lossless-encoded data length is equal to or smaller than a given threshold. (Note that the above thresholds are desirably determined depending on the tile size).

In step S15, if all the above conditions 1 to 4 are met, “lossless” is determined for the tile of interest; if any of the above conditions are not met, “lossy” is determined.

Note that the types of attributes to be calculated and the lossless/lossy determination conditions are merely examples, and they do not limit the present invention. For example, if at least one of conditions 1 to 4 is met, “lossless” may be determined. Since lossless encoding can perfectly restore an original tile, it is desirable to increase the possibility of determination of “lossless” in terms of image quality, and the load on the lossy encoding unit 115 can be reduced.

If “lossless” is determined in step S15, the process advances to step S16, and the lossless-encoded data generated by the lossless encoding unit 101 is output to the memory 111. At this time, an identification bit indicating “lossless-encoded data” is appended to the head of the encoded data.

On the other hand, if “lossy” is determined in step S15, the process advances to step S17 to output non-encoded data stored in the buffer 105 to the memory 111. At this time, a bit indicating “applying lossy encoding” is appended to the head of that data. In step S18, variable Ch is incremented by “1”. That is, the number of tiles determined as “lossy” is updated.

If the process advances to step S19, variable Ch and threshold Th(K) are compared. In the early stage of encoding for one page, since K=0, Th(K)=Th(0)=(N/100)×Tmax.

That is, step S19 checks if the data size determined as “lossy encoding” is equal to or lower than the encoding capability value N of the lossy encoding unit 115 for an image for one page, and the lossy encoding unit 115 can execute encoding.

Therefore, if Ch≦Th(K), the process advances to step S23 without executing the processes in steps S20 to S22.

If Ch>Th(K), this means that non-encoded data more than the encoding capability value N of the lossy encoding unit 115 are stored in the memory 111. Then, the process advances to step S20 to instruct the resolution converting unit 113 to start processing, so as to apply resolution reduction processing to non-encoded data stored in the memory 111.

Also, as for a tile input after the tile of interest, the resolution converting unit 107 must execute resolution conversion. Hence, the process advances to step S21 to double Rr. Furthermore, in step S22 variable K is incremented by “1” since resolution conversion has been done.

In step S23, variable Tc and the total number Tmax of tiles are compared. That is, it is checked if the lossless encoding phase for one page is completed. If NO in step S23, variable Tc is incremented by “1” in step S24, and the process returns to step S9.

If it is determined in step S23 that the lossless encoding phase for one page is complete, the process advances to step S25 to control the lossy encoding unit 115 to start lossy encoding processing of non-encoded data stored in the memory 111 (to be described in detail later). Note that whether or not the lossy encoding processing is completed is not checked in this case.

After that, it is checked in step S26 if the next page to be encoded still remains. If it is determined that the next page still remains, variable P is incremented by “1” in step S27 to start the processing in step S3 and subsequent steps. On the other hand, if it is determined in step S26 that the next page does not remain, a series of lossless encoding processes end.

The processing of the lossy encoding unit 115 upon reception of the processing start instruction in step S25 will be described below with reference to the flowchart of FIG. 22.

In step S31, the lossy encoding unit 115 lossy-encodes all non-encoded data (which can be determined based on their identification bits) stored in the memory 111 upon reception of the lossy encoding start instruction. The lossy encoding unit 115 re-stores lossy-encoded data in which a bit indicating lossy encoded data is appended to the head in the memory 111. In this case, the lossy encoding unit 115 also executes processing for deleting non-encoded data as original data of the lossy-encoded data from the memory 111. As a result, the encoded data (including lossless-encoded data and lossy-encoded data together) of a page indicated by variable P are generated on the memory 111.

The process advances to step S32 to convert the encoded data in the memory 111 and to store the converted data in the HDD 413 as a file. Note that data indicating the number of times of resolution conversion to be applied to the lossy-encoded data is written in the file header.

After that, a flag indicating completion of the lossy encoding & file storage processing (lossy encoding phase) indicated by variable P is set ON. This flag is checked in step S7 described above.

As described above, according to this embodiment, the encoding processing can be done according to the timings shown in FIG. 6. Especially, even when the capability value N of the lossy encoding unit 115 is exceeded in the lossless encoding phase, the non-encoded data size can be reduced to be equal to or smaller than the capability value N of the lossy encoding unit 115 by resolution conversion.

In the above embodiment, error processing (interruption) is executed if NO is determined in step S7. However, if this embodiment is applied to, e.g., a copying machine, and delay of the scan timing of the next document is permitted, the control may wait until YES is determined in step S7. That is, if NO in step S7, the process may return to step S7 again.

Second Embodiment

The second embodiment according to the present invention will be described hereinafter. FIG. 2 shows the basic arrangement of encoding processing according to the second embodiment. The operation of the encoding processing will be described below using FIGS. 11 and 12.

Note that the same reference numerals in FIG. 2 denote components having substantially the same functions as those in FIG. 1, and a description thereof will be omitted.

In the second embodiment, the encoded data size for one page falls within a predetermined setting code size based on the capability of the lossy encoding unit 115. To implement this, an arrangement for generating lossless-encoded data with different resolutions and a re-encoding unit for changing the compression ratio of lossy-encoded data are arranged. As a result, the code size can be adjusted finely.

A resolution converting unit 201 generates lossless-encoded data with different resolutions. The resolution converting unit 201 of this embodiment simultaneously generates, from input 2400-dpi tile data, image data which have resolutions of 1200 dpi and 600 dpi, which are ½ and ¼ the resolution of the input tile data.

Lossless encoding units 203 and 205 respectively generate lossless-encoded data from these image data with two different resolutions, and the lossless-encoded data are respectively stored in memory areas 111 b and 111 c. In FIG. 2, memory areas 111 a, 111 b, and 111 c are assured on the memory 111. However, these memory areas may be independent memories.

Note that the size of a tile as an encoding unit of the lossless encoding unit 101 is 32×32 pixels, while that of lossless encoding unit 203 is 16×16 pixels, and that of the lossless encoding unit 205 is 8×8 pixels. In this way, the lossless encoding units 101, 203, and 205 process different sizes of tiles, but the number of tiles per page can remain the same.

On the other hand, a re-encoding unit 211 is newly provided. This re-encoding unit 211 executes re-encoding processing of lossy-encoded data in the memory 111 in accordance with parameters which determine a compression encoding size. This re-encoding unit 211 decodes the lossy-encoded data to a level of quantized values or dequantized values, applies quantization again using a quantization step coarser than the previous step, and applies entropy-encoding again. In this manner, by changing the quantization step, a higher compression ratio is set to reduce the code size.

The processing contents of the second embodiment will be described below.

The lossless encoding phase within one page time period is substantially the same as that in the first embodiment, except that lossless encoding processing of the lossless encoding unit 203 using 16×16 pixels as one tile, and that of the lossless encoding unit 205 using 8×8 pixels as one tile are added.

Each of the lossless encoding units 101, 203, and 205 cumulatively counts the lossless-encoded data size for each tile. Therefore, the control unit 150 can detect the lossless-encoded data sizes for respective resolutions, which are stored in the memory areas 111 a, 111 b, and 111 c of the memory 111 at the end timing of one page time period, and can also detect if lossless-encoded data size of which resolution falls within the setting code size.

Assume that the memory area 111 a stores no non-encoded data (data to be lossy-encoded). In this case, the control unit 150 can select lossless-encoded data of a maximum resolution, which falls within the setting code size (target code size), of those in the memory areas 111 a, 111 b, and 111 c, and can output the selected data to the HDD 413. In case of an example shown in FIG. 11, the control unit 150 selects encoded data with a resolution of 2400 dpi for image A, and encoded data with a resolution of 1200 dpi for image B.

The processing executed when the memory area 111 a stores non-encoded data to be lossy-encoded will be described below.

In this embodiment, the lossy encoding unit 115 and re-encoding unit 211 adopt JPEG encoding. The code size generated by the JPEG encoding processing basically depends on a quantization table Qi used upon quantizing coefficients after DCT transformation. For this reason, assume that the lossy encoding unit 115 holds, as a table, the relationship between a standard quantization table Q0 and quantization tables Q1, Q2, . . . having larger quantization coefficients than the standard quantization table, and statistically obtained encoded data sizes upon encoding using the respective quantization tables.

In general, if the quantization step value in a quantization table used upon lossy encoding is small, a decoded image has high image quality, but its code size is large. Conversely, if a quantization table having a large quantization step value is used, the code size is reduced but image quality worsens.

In consideration of this point, the lossy-encoded data size is assured depending on the number of tiles determined as non-encoded data of an image within one page.

Let Mo be the setting code size. This setting code size need only be determined depending on the total number of pixels (or document size) of image data 401 to be encoded. Also, let Mok be a target lossless code size, and Moh be a target lossy code size. That is, the relation among these sizes is Mo=Mok+Moh.

Let Tck1 be the number of lossless-encoded tiles of encoded data stored in the memory area 111 a upon completion of lossless encoding processing within one page time period, and M(Tck1) be its code size. Also, let Tch (of course, Tch≦(N/100)×Tmax) be the number of tiles of non-encoded data stored in the memory area 111 a. Furthermore, let Tmax be the total number of tiles per page.

Also, let Tck2 be the number of tiles except for lossless-encoded data corresponding to the tile positions of non-encoded data stored in the memory area 111 a of those in the memory area 111 b, and M2(Tck2) be its code size. The number of tiles is the same as Tck1.

Likewise, let M3(Tck1) be a lossless code size of lower-resolution data corresponding to the tile positions of lossless-encoded data stored in the memory area 111 a of those in the memory area 111 c.

The target lossy code size Moh is calculated using a positive constant α which is set in advance (a may be appropriately set by the user) by: Moh=Mo×(Tch/Tmax)×α

That is, the target lossy code size is determined depending on the number Tch of tiles of non-encoded data in the total number Tmax of tiles. As a result, the target lossless code size Mok can be calculated by Mok=Mo−Moh.

A maximum lossless-encoded data size which does not exceed the target lossless code size Mok is determined from {M1(Tck1), M2(Tck1), M3(Tck1)}. This is equivalent to determination of the resolution.

Assume that a resolution of 2400 dpi is determined. The lossy-encoded data size per tile can be calculated by Moh/Tch. A quantization table Qi used to generate a code size which exceeds and is closest to Moh/Tch is determined. Then, the lossy encoding unit 115 actually executes lossy encoding processing of all non-encoded data stored in the memory area 111 a.

An actual lossy code size is not determined unless data is actually encoded, but it assumes a size several ten percentages of the maximum value, and a value obtained by adding the lossless code size is more likely to be equal to or smaller than the setting code size. FIG. 12 shows such example.

The lossy-encoded data size generated by the lossy encoding unit 115 may often exceed Moh. In this case, a quantization table Qi+1 is set in the re-encoding unit 211 to execute re-encoding processing. The re-encoding unit 211 executes up to entropy decoding processing of lossy-encoded data to reclaim up to quantized data. That is, the re-encoding unit 211 does not execute inverse DCT processing. When the re-encoding unit 211 reclaims up to the quantized data, it executes processing for executing re-quantization using the set quantization table Qi+1 (actually, a ratio “Qi+1/Qi”), then executing entropy encoding, and storing the encoded data in the memory area 111 a again. The re-encoding unit 211 executes this processing for all lossy-encoded data generated using the quantization table Qi. Every time the generated lossy-encoded data size exceeds Moh, quantization tables Qi+2, Qi+3, . . . are set in the re-encoding unit 211 to obtain lossy-encoded data whose size is equal to or smaller than Moh.

In this way, the lossless-encoded data in the memory area 111 a and lossy-encoded data whose size is equal to or smaller than the target lossy code size Moh are connected in the order of tiles, and are stored as a file in the HDD 413.

On the other hand, assume that the determined resolution is 1200 dpi. That is, this is the case wherein lossless-encoded data stored in the memory area 111 b are adopted. In this case, lossless-encoded data corresponding to tiles of non-encoded data stored in the memory area 111 a of those stored in the memory area 111 b are deleted. The lossless-encoded data remaining in the memory area 111 b and the lossy-encoded data whose size becomes equal to or smaller than the target lossy code size Moh are connected in the order of tiles, and are stored as a file in the HDD 413.

The same applies to a case wherein the determined resolution is 600 dpi. In this case, lossless-encoded data corresponding to tiles of non-encoded data stored in the memory area 111 a of those stored in the memory area 111 c are deleted. The lossless-encoded data remaining in the memory area 111 c and the lossy-encoded data whose size becomes equal to or smaller than the target lossy code size Moh are connected in the order of tiles, and are stored as a file in the HDD 413.

In either case, the header of the file stored in the HDD 413 stores information associated with the resolution of the lossy-/lossless-encoded data. Also, the file header stores a quantization matrix table used upon generating lossy-encoded data or information used to specify that table.

As described above, an output file is generated using the lossless-encoded data of the determined resolution and the lossy-encoded data, and is stored in the HDD 413. In case of the second embodiment, since lossless encoding and lossy encoding have the same resolution, the file header need only store information 1, ½, ¼, . . . ) indicating how much the resolution is decreased with respect to the original resolution.

In the second embodiment, in the lossy encoding phase, since the processing of the re-encoding unit 211 is added to that of the lossy encoding unit 115, the required processing time may increase. That is, the required processing time may exceed one page time period. To solve this problem, the capability value N of the lossy encoding unit 115 is set to be smaller than that of the first embodiment to have an enough margin.

According to the second embodiment, the following variations are available.

1. <Arrangement Without Re-Encoding Unit of Lossy Encoding>

In this arrangement, the resolution of lossless-encoded data is determined so that the sum of the lossy code size estimated from the non-encoded data size and the lossless code size becomes smaller than the setting code size. In this case, the actual code size (code size after lossy encoding) may become considerably smaller than the setting code size.

2. <Arrangement That Includes no Re-Encoding Unit of Lossy Encoding but in Which Lossy Encoding Unit Generates Two Types of Encoded Data with Different Compression Ratios>

In this case, lossy-encoded data with a higher compression ratio can be interpreted as that after re-encoding, and if the setting code size is exceeded using lossy-encoded data with a lower compression ratio, the lossy-encoded data with a higher compression ratio may be adopted.

Third Embodiment

The third embodiment will be described below. FIG. 3 is a block diagram showing the basic arrangement of the third embodiment, and the operation of the third embodiment will be described hereinafter using FIG. 13.

The third embodiment has substantially the same arrangement as that of the second embodiment, except that selection units 303 and 307, and memory areas 111 d and 111 e for storing encoded data output from these selection units are added to the arrangement of the second embodiment.

In the first and second embodiments, tile images to be lossless-encoded are not classified finely any more. In this embodiment, tile images to be lossless-encoded are classified based on, e.g., the numbers of tone levels, and may be handled in different resolutions.

In an image which includes character edge information as main information like a binary text image, the resolution is very significant. On the other hand, in a graphics image having a large number of tone levels, since the tone levels also take on a major significance as information, the weight of edge information relatively lowers, and the significance of the resolution is not so high rather than the binary text image.

Therefore, lossless-encoded image data can be classified into a region of an image which has a high significance of the resolution (H image region), and a region of an image which has a low significance of the resolution (L image region). The determination unit 103 makes this classification for respective tiles. The determination unit 103 receives image attribute information such as the number of tone levels and the like required for this classification from the lossless encoding unit 101.

The selection units 303 and 307 select lossless-encoded data with a higher resolution in the H image region and that with a lower resolution in the L image region, and store them in the memory areas 111 d and 111 e, respectively. Note that a bit indicating “lossless” and a bit indicating resolution information are appended to the header of each lossless-encoded data.

As a result, the memory area 111 d stores lossless-encoded data of H image of 2400 dpi and L image of 1200 dpi, and the memory area 111 e stores lossless-encoded data of H image of 1200 dpi and L image of 600 dpi.

FIG. 13 shows an example of a graph which represents the lossless-encoded data size including different resolutions described above, and the lossless-encoded data size with the same resolution. If there is no non-encoded data to be lossy-encoded, lossless-encoded data with a maximum resolution, whose size can fall within the setting code size need only be selected to generate encoded data. In case of the example shown in FIG. 13, encoded data in which the resolution of H image is 2400 dpi and that of L image is 1200 dpi are selected.

If there are non-encoded data to be lossy-encoded, the lossless-encoded data in which memory area is to be adopted need only be determined in accordance with the occupation ratio of these non-encoded data. However, in the third embodiment, since one output file includes encoded data with different resolutions, an identification bit of lossless/lossy, and a bit indicating a resolution are appended to each tile header. Since other control methods are the same as the second embodiment, a description thereof will be omitted.

Fourth Embodiment

The fourth embodiment according to the present invention will be described below. FIG. 14 is a block diagram showing the basic arrangement of an apparatus according to the fourth embodiment.

The fourth embodiment does not execute resolution conversion of data stored as non-encoded data in the memory 111. For this reason, this embodiment does not require the resolution converting unit 113 in FIG. 1.

Instead, this embodiment comprises a resolution converting unit 1401 which simultaneously generates data having resolutions of 1200 dpi and 600 dpi by resolution conversion from 2400-dpi tile data stored in the buffer 105. Image data having a size of 32×32 pixels at the resolution of 2400 dpi, that having a size of 16×16 pixels at the resolution of 1200 dpi, and that having a size of 8×8 pixels at 600 dpi are supplied to the selection unit 109.

When the determination result of the determination unit 103 is “lossy”, non-encoded data of a total of three different resolutions, i.e., 2400-dpi tile data output from the buffer 105 and 1200- and 600-dpi data generated by resolution conversion are stored in the memory 111.

The graph shown in FIG. 15 expresses how to store non-encoded data of the three different resolutions in the memory 111 within one page time period when the determination result of the determination unit 103 is “lossy” and continues. Data of respective resolutions are sequentially stored at a ratio proportional to the squares of resolutions, i.e., 16:4:1.

When the 2400-dpi non-encoded data size reaches N, the 1200- and 600-dpi non-encoded data sizes are respectively N/4 and N/16, and the total data size becomes (1+ 5/16)N. Therefore, the memory for storing non-encoded data requires a capacity larger by 5N/16 than the first embodiment.

When the 2400-dpi non-encoded data size exceeds N, since data of this resolution cannot be lossy-encoded within a predetermined period of time, these data are discarded (deleted) from the memory 111. Time T1 in FIG. 15 indicates this timing. At this time, the non-encoded data size stored in the memory is reduced from (1+ 5/16)N to 5N/16 at once. If one page time periods ends before T1, non-encoded data having the resolution of 2400 dpi can be lossy-encoded.

When the 2400-dpi non-encoded data are discarded at T1, non-encoded data having the resolutions of 1200 dpi and 600 dpi remain. After that, if the “lossy” determination result further continues, the non-encoded data sizes of the two different resolutions increase at a ratio of 4:1.

If the 1200-dpi non-encoded data size reaches N, the non-encoded data size of the resolution of 600 dpi becomes N/4, and the total data size becomes (1+¼)N=1.25N.

As in the case of 2400-dpi data, if the 1200-dpi non-encoded data size exceeds N, since data of this resolution cannot be lossy-encoded within a predetermined period of time, these 1200-dpi non-encoded data are discarded from the memory 111. Time T2 in FIG. 15 indicates this timing. After T2, only 600-dpi non-encoded data are stored.

In this manner, the resolution is switched from 2400 dpi to 1200 dpi and to 600 dpi, and non-encoded data of the resolution which is no longer required are discarded.

As can be seen from the above description, when non-encoded data of a plurality of resolutions exist on the memory 111 even after one page time period, the lossy encoding unit 115 executes encoding processing of non-encoded data of the highest resolution of those.

Since the fourth embodiment does not execute resolution conversion of data stored as non-encoded data in the memory 111, the need for complicated control associated with the resolution conversion can be obviated and the control can be simplified, but a memory size required to store non-encoded data increases slightly.

Assume that the 2400-dpi non-encoded data size upon switching the resolution from 2400 dpi to 1200 dpi is slightly decreased from N to 20N/21. Since a peak of the non-encoded data size is (1+ 5/16)N×20/21=1.25N, it assumes the same value as the peak at time T2. Therefore, an increase in memory size can be suppressed to N/4.

Fifth Embodiment

In the first to fourth embodiments, image data to be lossy-encoded by the lossy encoding processing unit 180 is stored in the memory 111 as non-encoded data. Therefore, the memory 111 must have a size enough to store the non-encoded data. The fifth embodiment will explain an example in which data to be encoded by the lossy encoding processing unit 180 is not non-encoded data but lossless-encoded data. In this way, the size of the memory 111 can be prevented from increasing.

FIG. 23 is a block diagram showing the basic arrangement of an apparatus according to the fifth embodiment. Note that the same reference numerals in FIG. 23 denote components having the same functions as those in FIG. 1 in the first embodiment, and a repetitive description thereof will be avoided.

The processing contents of the apparatus of the fifth embodiment will be described below.

The lossless encoding unit 101 receives image data for one tile (32×32 pixels) as a unit from image data 401, and lossless-encodes the received image data, thus generating lossless-encoded data. The lossless encoding unit 101 stores the generated lossless-encoded data in the memory 111. That is, the lossless encoding unit 101 temporarily lossless-encodes all the tiles of the image data. Upon lossless-encoding a certain tile, the lossless encoding unit 101 outputs attribute information of that tile to the determination unit 103. The determination unit 103 determines whether a tile of interest is to be lossy- or lossless-encoded, as in the first embodiment. The determination unit 103 appends the determination result (which can be expressed by 1 bit) to the head of the encoded data generated by the lossless encoding unit 101, and stores it in the memory 111. Note that 1 bit that indicates the determination result of the determination unit 103 is appended to the head of the encoded data. However, the present invention is not limited to this. At base, whether encoded data of each individual tile is to be lossless- or lossy-encoded can be identified. For example, a group of only the determination results of the determination unit 103 may be stored in the memory 111 independently of the encoded data.

The memory 111 stores the lossless-encoded data of all tiles of the image data 401. Note that the determination unit 103 counts the number of tiles which are determined to be lossy-encoded during the encoding processing of the lossless encoding processing unit 170.

Assume that the number of tiles to be lossy-encoded to the total number of tiles for one page, i.e., the lossy-encoding ratio is N % or less upon completion of the lossless-encoding processing of all the tiles of image data for one page. In this case, the control unit 150 controls the lossy encoding processing unit 180 as follows.

A lossless decoding unit 1601 reads lossless-encoded data which are determined to be lossy-encoded from the memory Ill, and decodes them. The lossless decoding unit 1601 outputs the results to the lossy encoding unit 115. The lossy encoding unit 115 lossy-encodes (JPEG-encodes) the decoded image data, and stores the lossy-encoded data in the memory 111. At this time, the lossy encoding unit 115 appends an identification bit indicating the lossy-encoded data to the head of the lossy-encoded data to be generated. The lossy encoding unit 115 deletes the original lossless-encoded data of the tile that is lossy-encoded. That is, the lossy encoding unit 115 replaces the lossless-encoded data by the lossy encoded data. The control unit 150 executes this processing for all the lossless-encoded data in the memory 111, which are determined to be lossy-encoded. As a result, the memory 111 stores the lossless- and lossy-encoded data together in association the image data for one page and outputs them to the HDD 413.

On the other hand, when the lossy-encoding ratio exceeds N % during the lossless-encoding processing of all the tiles of image data for one page, the control unit 150 controls the lossy encoding processing unit 180 as follows.

The lossless decoding unit 1601 reads lossless-encoded data which are determined to be lossy-encoded from the memory 111, and decodes them. The lossless decoding unit 1601 outputs the results to the resolution converting unit 113. The resolution converting unit 113 converts the both the horizontal and vertical resolutions of the decoded image data to ½ and outputs the converted data to a lossless encoding unit 1603. The lossless encoding unit 1603 lossless-encodes the resolution-converted image data to generate lossless-encoded data, and stores the generated lossless-encoded data in the memory 111. The lossless encoding unit 1603 appends an identification bit indicating that the data of interest is to be finally lossy-encoded to the head of the lossless-encoded data to be generated at that time. That is, the lossless encoding unit 1603 replaces the lossless-encoded data of a given resolution by those of a lower resolution. The control unit 150 executes this processing to lossless-encoded data to be lossy-encoded. These series of processes will be referred to as resolution conversion processing hereinafter.

Upon completion of the lossless-encoding processing of image data for one page by the lossless encoding processing unit 170, if the lossy-encoding ratio is higher than N % and is equal to or lower than 4N %, the lossy encoding processing unit 180 executes the same processing to be executed when the lossy-encoding ratio is equal to or lower than N %.

As can be seen from the above description, every time the lossy-encoding ratio exceeds each of thresholds N, 4N, and 16N during the lossless-encoding processing of image data for one page by the lossless encoding processing unit 170, the aforementioned resolution conversion processing (replacement processing) is recursively done. The lossless encoding processing unit 170 can lossy-encode the lossless-encoded data to be lossy-encoded in the memory 111 after completion of the lossless-encoding processing for one page by the lossless encoding processing unit 170, i.e., during a second page time period.

The processing sequences of the lossless encoding processing unit 170 and lossy encoding processing unit 180 according to the fifth embodiment will be described in more detail below.

FIG. 26 is a flowchart showing the control processing of the lossless encoding processing unit 170 by the control unit 150.

In step S41, the control unit 150 sets the numbers of tiles corresponding to the lossy-encoding ratios N, 4N, and 16N in thresholds Th(0) to Th(2) as in the first embodiment. In the block of step S41, Tmax is the total number of tiles included in image data for one page.

In step S42, the control unit 150 sets an initial value “0” in a variable K, and an initial value “0” in a variable CH. The variable K is required to select the threshold Th( ). Since the variable K is set with “0” as the initial value, the threshold Th(0) is selected in the early stage of encoding. The variable CH is required to count the number of tiles which are determined to be lossy-encoded.

The control unit 150 controls the lossless encoding unit 101 to input image data for one tile (32×32 pixels in this embodiment) in step S43 and to lossless-encode the image data in step S44. The determination unit 103 determines in step S45 in accordance with attribute information from the lossless encoding unit 101 if the image data of the tile of interest is to be lossless- or lossy-encoded. This determination step is attained by checking if the same conditions as in the first embodiment are satisfied, and a detailed description thereof will not be given.

If the determination unit 103 determines in step S45 that the tile of interest is to be lossless-encoded, the process advances to step S46 to store the encoded data appended with a lossless flag indicating that the tile of interest is to be lossless-encoded in the memory 111. After that, the process advances to step S52.

On the other hand, if the determination unit 103 determines in step S45 that the tile of interest is to be lossy-encoded, the process advances to step S47 to store the encoded data appended with a lossy flag indicating that the tile of interest is to be lossy-encoded in the memory 111. In step S48, the control unit 150 increments the variable CH by “1” to count up the number of tiles which are determined to be lossy-encoded. After that, the control unit 150 compares the variable CH and threshold Th(K) in step S49. If the control unit 150 detects that CH≦Th(K), since the lossy encoding processing unit 180 located at the subsequent stage can complete lossy encoding processing within one page time period, the process advances to step S52.

On the other hand, if the control unit 150 detects in step S49 that CH>Th(K), i.e., that the number of tiles to be lossy-encoded exceeds the capability of the lossy encoding processing unit 180, the process advances to step S50, and the control unit 150 requests the lossy encoding processing unit 180 to execute resolution conversion processing. As a result, the lossy encoding processing unit 180 starts the resolution conversion of lossless-encoded data which is stored in the memory 111 and is appended with the lossy flag. Details of this resolution conversion processing in the lossy encoding processing unit 180 will be described later. The process then advances to step S51 to increment the variable K by “1”. After that, the process advances to step S52.

The control unit 150 checks in step S52 if the tile of interest is the last tile of the page. If NO in step S52, the process returns to step S43 to lossless-encode the next tile.

On the other hand, if the control unit 150 detects that the tile of interest is the last tile of the page, it requests the lossy encoding processing unit 180 to start lossy encoding in step S53. The control unit 150 checks in step S54 if image data of the next page remains. If the control unit 150 detects that image data of the next page remains, it repeats the processes in step S41 and subsequent steps.

Next, the control processing of the lossy encoding processing unit 180 by the control unit 150 according to the fifth embodiment will be described below with reference to the flowchart of FIG. 27.

The lossy encoding processing unit 180 checks in step S61 if it receives a resolution conversion request and in step S62 if it receives a lossy encoding start request. That is, the lossy encoding processing unit 180 waits for reception of one of these requests in steps S61 and S62.

Upon reception of the resolution conversion request, the process advances to step S63, and the control unit 150 controls the lossless decoding unit 1601 to read the lossless-encoded data of one tile which is stored in the memory 111 and is appended with the lossy flag, and to execute the decoding processing of the read lossless-encoded data in step S64. In step S65, the control unit 150 controls the resolution converting unit 113 to convert both the horizontal and vertical resolutions of the decoded image data of one tile into ½. In step S66, the control unit 150 controls the lossless encoding unit 1603 to lossless-encode the resolution-converted image data. As a result, since the lossless-encoded data is generated, the control unit 150 sets a lossy flag at the head of that data, and stores it in the memory 111. At this time, the control unit 150 deletes the lossless-encoded data of the tile of interest before resolution conversion from the memory 111.

After that, the process advances to step S68 to determine if the resolution conversion of all the lossless-encoded data with the lossy flag is complete. If the resolution conversion is not complete yet, the control unit 150 repeats the processes in step S63 and subsequent steps.

The lossless encoding processing unit 170 may output a resolution conversion request a plurality of times to the lossy encoding processing unit 180 during lossless encoding of image data for one page. In this case, the processes in step S63 and subsequent steps are recursively executed.

Assume that the lossy encoding processing unit 180 receives the lossy encoding start request from the lossless encoding processing unit 170. This indicates that the lossless encoding processing unit 170 completes the lossless encoding processing for one page. Therefore, the control unit 150 controls to execute the processes in step S69 and subsequent steps.

The control unit 150 controls the lossless decoding unit 1601 to read the lossless-encoded data, which is stored in the memory 111 and has the lossy flag, in step S69, and to execute the decoding processing of the read data in step S70. In step S71, the control unit 150 controls the lossy encoding unit 115 to execute the lossy encoding processing of the decoded image data (one of 32×32 pixels, 16×16 pixels, and 8×8 pixels) for one tile. In step S72, the control unit 150 appends a lossy flag at the head of the generated lossy-encoded data, and stores it in the memory 111. At this time, the control unit 150 deletes the lossless-encoded data of the tile of interest from the memory 111.

The control unit 150 checks in step S73 if the lossy-encoding processing of all lossless-encoded data appended with the lossy flag in one page is complete. If NO in step S73, the control unit 150 repeats the processes in step S69 and subsequent steps. If the control unit 150 detects that the lossy-encoding processing in one page is complete, it outputs the lossless-encoded data and lossy-encoded data stored in the memory 111 to the HDD 413 as a file. The process then returns to step 561 to prepare for the lossy-encoding processing of the next page.

As described above, according to the fifth embodiment, since the memory of the lossy encoding processing unit 180 never stores non-compressed image data, the size of the memory 111 can be reduced. Also, since the lossless encoding processing unit 170 can be comprised of only the lossless encoding unit 101 in practice, the apparatus arrangement can also be simplified.

Sixth Embodiment

The sixth embodiment according to the present invention will be described hereinafter. FIG. 24 is a block diagram showing the basic arrangement of an apparatus according to the sixth embodiment. To help you understand, the sixth embodiment is a combination of the fourth and fifth embodiments. The same reference numerals in FIG. 24 denote components having, in practice, the same functions as those described so far, and a repetitive description thereof will be avoided.

In the sixth embodiment, the difference from the fifth embodiment lies in that the lossy encoding processing unit 180 does not execute any resolution conversion processing, and the lossless encoding processing unit 170 executes processing corresponding to the resolution conversion. The processing contents of the sixth embodiment will be described below with reference to FIG. 24.

The lossless encoding unit 101 lossless-encodes a tile of 32×32 pixels at 2400 dpi. The resolution converting unit 1401 generates image data of 16×16 pixels (1200 dpi) and that of 8×8 pixels (600 dpi) from the tile of 32×32 pixels, which is to be encoded by the lossless encoding unit 101, and outputs these image data to lossless encoding units 1701 and 1703.

As a result of the above configuration, lossless-encoded data of 2400 dpi, 1200 dpi, and 600 dpi are generated for one tile.

As has been described in the above embodiments, the determination unit 103 determines according to attribute information whether the tile of interest is to be lossless- or lossy-encoded. Then, the determination unit counts the number of tiles which are determined to be lossy-encoded in CH.

When the determination unit 103 determines that the image data of the tile of interest is to be lossless-encoded, only encoded data generated by the lossless encoding unit 101 is stored in the memory 111. That is, the encoded data generated by the lossless encoding units 1701 and 1703 are not stored in the memory 111. At this time, a 1-bit lossless flag indicating that the data of interest is to be lossless-encoded is appended at the head of the encoded data, and the data is stored in the memory 111.

On the other hand, the processing of the control unit 150 when the determination unit 103 determines that the image data of the tile of interest is to be lossy-encoded is as follows. Note that FIG. 28 shows an example of transition of CH that the determination unit 103 counts the number of tiles to be lossy-encoded. When CH≦(N/100)×Tmax  (1)

The control unit 150 controls to store the three different types of lossless-encoded data generated by the lossless encoding units 101, 1701, and 1703 in the memory 111. The control unit 150 appends a 1-bit lossy fag indicating that the data of interest to be lossy-encoded at the head of each encoded data, and stores the encoded data in the memory 111. When (N/100)×Tmax<CH≦(N/100)×4×Tmax  (4)

When CH exceeds “(N/100)×Tmax” (timing T1 in FIG. 28), the control unit 150 requests the lossy encoding processing unit 180 to delete the 2400-dpi encoded data having the lossy flag of those which have already stored in the memory 111. After this, the control unit 150 controls a selection unit 1705 to store two different types of lossless-encoded data of 1200 dpi and 600 dpi generated by the lossless encoding units 1701 and 1703 in the memory 111. That is, the selection unit 1705 does not store in the memory 111 any lossless-encoded data of 2400 dpi generated by the lossless encoding unit 101. When (N/100)×4×Tmax<CH≦(N/100)×16×Tmax  (3)

When CH exceeds “(N/100)×4×Tmax” (timing T2 in FIG. 28), the control unit 150 requests the lossy encoding processing unit 180 to delete the 1200-dpi encoded data having the lossy flag of those which have already stored in the memory 111. After this, the control unit 150 controls the selection unit 1705 to store only lossless-encoded data of 600 dpi generated by the lossless encoding unit 1703 in the memory 111. When (N/100)×16×Tmax<CH  (4)

When CH exceeds “(N/100)×16×Tmax” (timing T3 in FIG. 28), the lossy encoding processing unit 180 can no longer execute lossy encoding within one page time period. Thus, the control unit 150 interrupts the encoding processing, and informs an external unit of an error.

In this embodiment, since the maximum tile size is 32×32 pixels, and image data of three different resolutions are generated, when the above condition (N/100)×16×Tmax<CH is met, an error is generated. For example, assume that the maximum tile size is 64×64 pixels, and lossless encoding units for image data of four different resolutions are arranged. In this case, the encoding processing can be continued even when the condition (N/100)×16×Tmax<CH≦(N/100)×64×Tmax is met, as is apparent to those who are skilled in the art.

The transitions of the data sizes of lossless-encoded data of the resolutions of 2400 dpi, 1200 dpi, and 600 dpi, which are stored in the memory 111 and have the lossy flag, according to the sixth embodiment are equivalent to those shown in FIG. 15. However, “non-compressed data” on the ordinate of FIG. 15 must be replaced by “lossless-encoded data size with lossy flag”. Also, timings T1 and T2 in FIG. 15 correspond to timings T1 and T2 in FIG. 28.

The processing of the lossy encoding processing unit 180 in the sixth embodiment is as follows.

(1) Upon reception of a delete request of lossless-encoded data of resolution R (R=one of 2400, 1200, and 600) with the lossy flag from the control unit 150, the lossy encoding processing unit 180 deletes corresponding encoded data from the memory 111.

(2) Upon completion of the lossless encoding processing for one page by the lossless encoding processing unit 170, the lossy encoding processing unit 180 decodes all the lossless-encoded data of the maximum resolution with the lossy flag stored in the memory 111 using the lossless decoding unit 1601, and lossy-encodes the decoded data using the lossy encoding unit 115. The unit 180 appends a lossy flag at the head of each lossy-encoded data generated by the lossy encoding unit 115, and stores that data in the memory 111. At this time, the unit 180 deletes the lossless-encoded data with the lossy flag. (3) Upon completion of the lossy encoding processing, the lossy encoding processing unit 180 converts the lossless-encoded data with the lossless flag and lossy-encoded data with the lossy flag, which are stored in the memory 111, into a predetermined format, and stores them in the HDD 413.

The processing contents of the lossless encoding processing unit 170 and lossy encoding processing unit 180 by the control unit 150 in FIG. 24 according to the sixth embodiment will be described below with reference to the flowcharts of FIGS. 29 and 30.

The processing sequence of the lossless encoding processing unit 170 in FIG. 24 will be described first with reference to the flowchart of FIG. 29.

In step S81, the control unit 150 sets the numbers of tiles corresponding to the lossy-encoding ratios N, 4N, and 16N in thresholds Th(0) to Th(2) as in the first embodiment. In the block of step S81, Tmax is the total number of tiles included in image data for one page.

In step S82, the control unit 150 sets an initial value “0” in a variable K, and an initial value “0” in a variable CH. The variable K is required to select the threshold Th( ). The variable CH is required to count the number of tiles which are determined to be lossy-encoded.

In step S83, the control unit 150 controls the lossless encoding unit 101 to input image data of 2400 dpi for one tile (32×32 pixels in this embodiment). In step S84, the control unit 150 controls the resolution converting unit 1401 to execute resolution conversion of the input tile so as to generate data of 16×16 pixels of the resolution of 1200 dpi, and data of 8×8 pixels of the resolution of 600 dpi. In step S85, the control unit 150 controls the lossless encoding units 101, 1701, and 1703 to execute lossless encoding.

In step S86, the control unit 150 controls the determination unit 103 to determine in accordance with attribute information from the lossless encoding unit 101 if the image data of the tile of interest is to be lossless- or lossy-encoded. This determination step is attained by checking if the same conditions as in the first embodiment are satisfied, and a detailed description thereof will not be given.

If the determination unit 103 determines in step S86 that the tile of interest is to be lossless-encoded, the process advances to step S87 to append a lossless flag to the head of the lossless-encoded data generated by the lossless encoding unit 101 and to store that data in the memory 111. That is, the lossless-encoded data generated by the lossless encoding units 1701 and 1703 are not stored in the memory 111. The process then advances to step S96.

On the other hand, if the determination unit 103 determines in step S86 that the tile of interest is to be lossy-encoded, the process advances to step S88. The control unit 150 checks in step S88 which of values 0, 1, and 2 the variable K assumes.

If K=0, the control unit 150 stores the lossless-encoded data of 2400 dpi appended with the lossy flag in the memory 111 in step S89. The lossless-encoded data of 2400 dpi is data generated by the lossless encoding unit 101.

If K=1 or K=0, the control unit 150 stores the lossless-encoded data of 1200 dpi appended with the lossy flag in the memory 111 in step S90. The lossless-encoded data of 1200 dpi is data generated by the lossless encoding unit 1701.

If K=2, K=1, or K=0, the control unit 150 stores the lossless-encoded data of 600 dpi appended with the lossy flag in the memory 111 in step S91. The lossless-encoded data of 600 dpi is data generated by the lossless encoding unit 1703.

With the above processes, if K=0, the memory 111 stores the lossless-encoded data of the resolutions of 2400 dpi, 1200 dpi, and 600 dpi. If K=1, the memory 111 stores the lossless-encoded data of the resolutions of 1200 dpi and 600 dpi. If K=2, the memory 111 stores only the lossless-encoded data of the resolution of 600 dpi.

In step S92, the control unit 150 increments the variable CH by “1” to count up the number of tiles which are determined to be lossy-encoded. After that, the control unit 150 compares the variable CH and threshold Th(K) in step S93. If the control unit 150 detects that CH≦Th(K), since this means that the lossy encoding processing unit 180 located at the subsequent stage can lossy-encode the lossless-encoded data of the maximum resolution at the current timing, the process advances to step S96.

On the other hand, if the control unit 150 detects in step S93 that CH>Th(K), the process advances to step S94, and the control unit 150 requests the lossy encoding processing unit 180 to delete the lossless-encoded data of the maximum resolution appended with the lossy flag of those stored in the memory 111.

For example, if K=0 and CH>Th(0), this means that the lossy encoding processing unit 180 can no longer lossy-encode lossless-encoded data of 2400 dpi with the lossy flag within one page time period. Thus, the control unit 150 requests the lossy encoding processing unit 180 to delete the lossless-encoded data of the resolution of 2400 dpi having the lossy flag of those stored in the memory 111. As a result, the maximum resolution of lossless-encoded data which remain stored in the memory 111 and are appended with the lossy flag is 1200 dpi.

After that, in step S95 the control unit 150 increments the variable K by “1”, and the process advances to step S96.

The control unit 150 checks in step S96 if the tile of interest is the last tile of the page. If NO in step S96, the process returns to step S83 to lossless-encode the next tile.

On the other hand, if the control unit 150 detects in step S96 that the tile of interest is the last tile of the page, it requests the lossy encoding processing unit 180 to start lossy encoding in step S97. The control unit 150 checks in step S98 if image data of the next page remains. If the control unit 150 detects that image data of the next page remains, it repeats the processes in step S81 and subsequent steps.

Next, the control processing of the lossy encoding processing unit 180 by the control unit 150 according to the sixth embodiment will be described below with reference to the flowchart of FIG. 30.

The lossy encoding processing unit 180 checks in step S101 if it receives a delete request and in step S102 if it receives a lossy encoding start request. That is, the lossy encoding processing unit 180 waits for reception of one of these requests in steps S101 and S102.

If the lossy encoding processing unit 180 detects that it receives the delete request, the process advances to step S103, and the unit 180 deletes all encoded data with the requested resolution of the lossless-encoded data with the lossy flag in the memory 111.

If the lossy encoding processing unit 180 detects that it receives the lossy encoding start request, the process advances from step S102 to step S104.

The control unit 150 controls the lossless decoding unit 1601 to read the lossless-encoded data for one tile having the maximum resolution of those, which have the lossy flag and are stored in the memory 111, in step S104, and to execute the decoding processing of the read data in step S105. In step S106, the control unit 150 controls the lossy encoding unit 115 to execute the lossy encoding processing of the decoded image data. As a result, since the lossy-encoded data is generated, the control unit 150 appends a lossy flag at the head of that data, and stores the data in the memory 111 in step S107. At this time, the control unit 150 deletes the lossless-encoded data corresponding to the tile of interest and those of other resolutions from the memory 111.

After that, the process advances to step S108 to check if the lossy-encoding processing of all lossless-encoded data with the lossy flag is complete. If NO in step S108, the control unit 150 repeats the processes in step S104 and subsequent steps. If the control unit 150 detects that the lossy-encoding processing of all the lossless-encoded data with the lossy flag is complete, the process advances to step S109. In step S109, the control unit 150 converts the lossless-encoded data with the lossless flag and lossy-encoded data stored with the lossy flag, which are stored in the memory 111, into an appropriate format, and outputs them to the HDD 413. The process then returns to step S101 to prepare for the lossy-encoding processing of the next page.

As described above, according to the sixth embodiment, since the need for the arrangement for executing resolution conversion in the lossy encoding processing unit 180 is obviated compared to the fifth embodiment, the arrangement can be simplified.

Seventh Embodiment

The seventh embodiment will explain an example in which the control is made to make the data size of an image for one page after lossless- and lossy-encoding processes fall within a target code size range.

In the sixth embodiment, data of a plurality of resolutions are generated for a tile which is determined to be lossy-encoded, and encoded data obtained by lossless-encoding these data are held. In the seventh embodiment, in addition to these data, data of a plurality of resolutions are also generated for a tile which is determined to be lossless-encoded, and encoded data obtained by lossless-encoding these data are held.

FIG. 25 is a block diagram of an apparatus according to the seventh embodiment. The same reference numerals in FIG. 25 denote the same components as in FIG. 24 of the sixth embodiment, and a repetitive description thereof will be avoided. Large differences from FIG. 24 are that a code size counting unit 1801 is arranged and the selection unit 1705 is omitted.

The processing contents of the apparatus according to the seventh embodiment are as follows.

The lossless encoding processing unit 170 generates lossless-encoded data of resolutions of 2400 dpi, 1200 dpi, and 600 dpi for one tile, and stores them in the memory 111. At this time, the determination unit 103 determines if the tile of interest is to be lossless- or lossy-encoded, as in the embodiments described so far, and appends the determination result as a lossless or lossy flag at the head of each encoded data. Also, the determination unit 103 counts the number CH of tiles which are determined to be lossy-encoded.

The code size counting unit 1801 has three lossless code size counters LK(0), LK(1), and LK(2) for counting lossless code sizes, and one lossy code size counter LH.

The counter LK(0) is used to cumulatively add the sizes (each including the flag bit) of encoded data of 2400 dpi of tiles which are determined by the determination unit 103 to be lossless-encoded. The counter LK(1) is used to cumulatively add the sizes of encoded data of 1200 dpi of tiles which are determined by the determination unit 103 to be lossless-encoded. The counter LK(2) is used to cumulatively add the sizes of encoded data of 600 dpi of tiles which are determined by the determination unit 103 to be lossless-encoded. Note that the counter LH will be described later.

Upon completion of the encoding processing for one page by the lossless encoding processing unit 170, the control unit 150 controls the lossy encoding processing unit 180 to execute the following processing based on the counted number CH of tiles to be lossy-encoded, which is counted by the determination unit 103. When CH≦(N/100)×Tmax  (1)

When this condition is met, the lossy encoding processing unit 180 can lossy-encode all tiles of 2400 dpi with the lossy flag within one page time period. Thus, the lossless decoding unit 1601 of the lossy encoding processing unit 180 decodes the lossless-encoded data of 2400 dpi with the lossy flag, which is stored in the memory 111. The lossy encoding unit 115 lossy-encodes the decoded tile image, appends a lossy flag at the head of the generated lossy-encoded data, and stores that data in the memory 111. At this time, the code size counting unit 1801 cumulatively adds the encoded data size generated by the lossy encoding unit 115 to the internal counter LH. The aforementioned processing is repeated for all lossless-encoded data of 2400 dpi having the lossy flag, which are stored in the memory 111.

As a result of the above processing, the counter LH stores the total data size of lossy-encoded data of 2400 dpi with the lossy flag. When (N/100)×Tmax<CH≦(N/100)×4×Tmax  (2)

When this condition is met, the lossy encoding processing unit 180 can lossy-encode all tiles of 1200 dpi with the lossy flag within one page time period. Thus, the lossless decoding unit 1601 of the lossy encoding processing unit 180 decodes the lossless-encoded data of 1200 dpi with the lossy flag, which is stored in the memory 111. The lossy encoding unit 115 lossy-encodes the decoded tile image, appends a lossy flag at the head of the generated lossy-encoded data, and stores that data in the memory 111. At this time, the code size counting unit 1801 cumulatively adds the encoded data size generated by the lossy encoding unit 115 to the internal counter LH. The aforementioned processing is repeated for all lossless-encoded data of 1200 dpi having the lossy flag, which are stored in the memory 111.

As a result of the above processing, the counter LH stores the total data size of lossy-encoded data of 1200 dpi with the lossy flag. When (N/100)×4×Tmax<CH≦(N/100)×16×Tmax  (3)

When this condition is met, the lossy encoding processing unit 180 can lossy-encode all lossy-flag tiles of 600 dpi within one page time period. Thus, the lossless decoding unit 1601 of the lossy encoding processing unit 180 decodes the lossless-encoded data of 600 dpi with the lossy flag, which is stored in the memory 111. The lossy encoding unit 115 lossy-encodes the decoded tile image, appends a lossy flag at the head of the generated lossy-encoded data, and stores that data in the memory 111. At this time, the code size counting unit 1801 cumulatively adds the encoded data size generated by the lossy encoding unit 115 to the internal counter LH. The aforementioned processing is repeated for all lossless-encoded data of 600 dpi having the lossy flag, which are stored in the memory 111.

As a result of the above processing, the counter LH stores the total data size of lossy-encoded data of 600 dpi with the lossy flag. When (N/100)×16×Tmax<CH  (4)

When this condition is met, this means that the lossy encoding processing unit 180 can no longer lossy-encode within one page time period. Therefore, the processing is interrupted, and an error message is displayed.

Upon completion of the lossy-encoding processing by the lossy encoding processing unit 180 in the processes (1) to (3) above, the control unit 150 determines the resolution of lossless-encoded data to be output based on the counters LK(0), LK(1), LK(2), and LH held in the code size counting unit 1801, and a target code size LT according to the size of image data to be encoded.

That is, the control unit 150 calculates a minimum variable i (i=0, 1, 2) which meets: LK(i)+LH≦LT Since the value obtained by subtracting the lossy-encoded data size LH from the target code size LT is the capacity that can be assigned to lossless-encoded data, the above inequality means to explore the lossless-encoded data size of the maximum resolution equal to or smaller than that assigned size.

If i=0, the control unit 150 determines 2400 dpi as the resolution of lossless-encoded data to be output.

After the resolution of lossless-encoded data to be output is determined in this way, the control unit 150 sets the resolution to be output in the lossy encoding processing unit 180 and controls it to execute output processing.

When the above setting is made, the lossy encoding processing unit 180 stores the lossless-encoded data with the lossless flag and lossy-encoded data with the lossy flag, which have the set resolution, in the HDD 413 as a file. At this time, the unit 180 also stores the tile sizes (resolution) of the lossy- and lossless-encoded data in a file header. Also, the unit 180 deletes data which are stored in the memory 111 and are associated with a page of interest.

The control contents of the lossless encoding processing unit 170 and lossy encoding processing unit 180 by the control unit 150 in FIG. 25 according to the seventh embodiment will be described below with reference to the flowcharts of FIGS. 31 and 32.

The processing sequence of the lossless encoding processing unit 170 in FIG. 25 will be described first with reference to the flowchart of FIG. 31.

In step S121, the control unit 150 clears the counters LK(0) to LK(2) in the code size counting unit 1801 to zero, and also the counter CH in the determination unit 103 to zero.

In step S122, the control unit 150 controls the lossless encoding unit 101 to input image data for one tile (32×32 pixels in this embodiment) of image data of 2400 dpi. In step S123, the control unit 150 controls the resolution converting unit 1401 to execute resolution conversion of the input tile so as to generate 16×16 pixel data of the resolution of 1200 dpi and 8×8 pixel data of the resolution of 600 dpi. In step S124, the control unit 150 controls the lossless encoding units 101, 1701, and 1703 to execute lossless encoding.

The control unit 150 controls the determination unit 103 to determine in step S125 whether the image data of the tile of interest is to be lossless- or lossy-encoded. This determination step is attained by checking if the same conditions as in the first embodiment are satisfied, and a detailed description thereof will not be given.

If the determination unit 103 determines in step S125 that the tile of interest is to be lossless-encoded, the process advances to step S126. In step S126, the control unit 150 adds the size of the lossless-encoded data of the resolution of 2400 dpi to the counter LK(0) in the code size counting unit 1801. Likewise, the control unit 150 respectively adds the sizes of the lossless-encoded data of the resolutions of 1200 dpi and 600 dpi to the counters LK(1) and LK(2) in the code size counting unit 1801. Note that the control unit 150 also adds one more bit for a flag upon adding the data size.

In step S127, the control unit 150 stores the encoded data of 2400 dpi, 1200 dpi, and 600 dpi appended with a lossless flag in the memory 111. The process then advances to step S130.

On the other hand, if the determination unit 103 determines in step S125 that the tile of interest is to be lossy-encoded, the process advances to step S128. In step S128, the control unit 150 appends a lossy flag at the head of each of the lossless-encoded data of 2400 dpi, 1200 dpi, and 600 dpi, and stores these data in the memory 111. In step S129, the control unit 150 increments the variable CH by “1”.

The control unit 150 checks in step S130 if the tile of interest is the last tile of the page. If NO in step S130, the process returns to step S122 to lossless-encode the next tile.

On the other hand, if the control unit 150 determines in step S130 that the tile of interest is the last tile of the page, it requests the lossy encoding processing unit 180 to start lossy encoding in step S131. The control unit 150 checks in step S132 if image data of the next page remains. If the control unit 150 determines that image data of the next page remains, it repeats the processes in step S121 and subsequent steps.

The control processing for the lossy encoding processing unit 180 by the control unit 150 according to the seventh embodiment will be described below with reference to the flowchart of FIG. 32.

The lossy encoding processing unit 180 checks in step S141 if it receives a lossy encoding start request. If the unit 180 determines that it receives the lossy encoding start request, the control unit 150 executes determination processes in steps S142 and S143.

The control unit 150 checks in step S142 if the number CH of tiles to be lossy-encoded, which is determined by the determination unit 103, meets CH≦(N/100)×Tmax. The control unit 150 checks in step S143 if the number CH of tiles to be lossy-encoded, which is determined by the determination unit 103, meets (N/100)×Tmax<CH≦(N/100)×4×Tmax.

If the condition of step S142 is met, since the lossy encoding processing unit 180 can lossy-encode tiles of 2400 dpi, the control unit 150 decides 2400 dpi as the resolution of data to be lossy-encoded. On the other hand, if the condition of step S143 is met, since the lossy encoding processing unit 180 can lossy-encode tiles of 1200 dpi, the control unit 150 decides 1200 dpi as the resolution of data to be lossy-encoded. If the condition of step S143 is not met, the control unit 150 decides 600 dpi as the resolution of data to be lossy-encoded.

After the resolution of data to be lossy-encoded of the lossless-encoded data, which are stored in the memory 111 and are appended with the lossy flag, is decided, as described above, the process advances to step S147.

In step S147, the control unit 150 controls to clear the counter LH in the code size counting unit 1801 to zero. The control unit 150 requests the lossless decoding unit 1601 to read the lossless-encoded data for one tile, which has the resolution decided in the previous processing and also the lossy flag in step S148, and controls the unit 150 to execute decoding processing in step S149. In step S150, the control unit 150 controls the lossy encoding unit 115 to lossy-encode the image data decoded by the lossless decoding unit 1601. As a result, since the lossy encoding unit 115 outputs the lossy-encoded data, the control unit 150 adds its data size +1 in the counter LH in the code size counting unit 1801 in step S151. The reason why “1” is added is that the flag bit is included. In step S152, the control unit 150 stores the lossy-encoded data appended with the lossy flag in the memory 111.

After that, the process advances to step S153 to check if lossy encoding is complete. If NO in step S153, the control unit 150 repeats the processes in step S148 and subsequent steps. On the other hand, if it is determined that the lossy-encoding processing for all lossless-encoded data of the decided resolution having the lossy flag is complete, the process advances to step S154. In step S154, the control unit 150 calculates LK( ) of the maximum resolution, which falls within the difference between the target code size LT and the counter LH held in the code size counting unit 1801, as described above.

Then, in step S155 the control unit 150 outputs the lossless-encoded data of the decided resolution with the lossless flag and lossy-encoded data with the lossy flag obtained by executing the lossy-encoding processing in an appropriate format to the hard disk 413. In this case, the control unit 150 stores the respective tile sizes (or resolutions) of the lossy- and lossless-encoded data in a file header. The process then returns to step S141 to prepare for the lossy-encoding processing of the next page.

As described above, according to the seventh embodiment, the encoded data size to be finally generated can be limited to the target data size LT or less in addition to the process of the sixth embodiment.

The embodiments of the encoding apparatus according to the present invention have been described.

A decoding apparatus according to each of the embodiments will be described hereinafter.

Decoding Apparatus Corresponding to First, Fifth, and Sixth Embodiments

FIG. 16 shows the arrangement of an apparatus for decoding encoded data generated by the image processing apparatus of the first, fifth, and sixth embodiments. FIG. 16 will be described below using the timing chart of decoding processing shown in FIG. 18.

As in the encoding processing which requires two page time periods, the decoding processing requires two page time periods.

Encoded data stored in the hard disk drive 413 is transferred to a memory 111′ for each page. This encoded data includes those which are lossless- or lossy-encoded for respective tiles. A file header also stores information indicating the number of times of resolution conversion upon generating lossy-encoded data, or indicating the resolution of the lossy-encoded data.

During the first page time period, a lossy decoding unit 2601 executes decoding processing of lossy-encoded data for respective tiles, and stores them in the memory 111′ again.

This lossy decoding unit 2601 requires a processing capability of N % or more, and a memory size N % of the image data size for one page is required to store decoded non-encoded data.

During the second page time period, a lossless decoding unit 2603 executes decoding processing of lossless-encoded data for respective tiles, and outputs them as image data 2609.

Also, the lossy-decoded tile data require conversion for increasing the resolution by the number of times of resolution conversion. For example, when the file header stores information indicating that the resolution conversion is executed twice (or information indicating that the resolution of the lossy-encoded data is ¼ the original resolution), a resolution converting unit 2605 enlarges the number of pixels of the image obtained by the lossy decoding unit 2601 to 2²=4 times in both the horizontal and vertical directions. The enlargement processing may be attained by repeating one decoded pixel by 4×4 pixels, or increasing the number of pixels by linearly interpolating neighboring decoded pixels. When the number of times of resolution conversion is zero, i.e., when the resolution of the lossy-encoded data is 2400 dpi, the resolution converting unit 2605 outputs the input data intact without any processing.

With the aforementioned decoding processing, the encoded data generated by the first, fifth, and sixth embodiments can be decoded to original data.

Decoding Apparatus Corresponding to Second to Fourth and Seventh Embodiments

FIG. 17 shows the arrangement of an apparatus for decoding encoded data generated by the image processing apparatus of the second to fourth and seventh embodiments. The decoding processing is executed based on the timing chart shown in FIG. 18 as in the arrangement of FIG. 16.

The decoding processing of FIG. 17 is basically the same as that of the arrangement in FIG. 16, except for the following points.

(1) Data decoded by the lossy decoding unit 2601 are not directly stored in the memory 1111 but are encoded by a lossless encoding unit 2701 and are then stored in the memory 111′.

(2) All data are temporarily converted into lossless-encoded data.

(3) All encoded data are lossless-decoded within the second page time period.

(4) The resolution converting unit 2605 executes resolution conversion processing for data after lossless decoding with reference to the file header in accordance with their resolutions. All data after resolution conversion are 2400-dpi image data 2609.

With the aforementioned decoding processing, the encoded data generated by the second to fourth and seventh embodiments can be decoded to original data.

In the description of the above embodiments, JPEG-LS is adopted as lossless encoding, and JPEG is adopted as lossy encoding. However, the present invention is not limited to these specific encoding schemes. Other lossless and lossy encoding techniques may be adopted. However, like the relationship between JPEG-LS and JPEG, two encoding techniques one of which is suited to images with a fewer number of tone levels, the other of which is suited to images such as natural images with a large number of tone levels, and which have a complementary relationship, are desirably adopted.

While the present invention has been described with reference to exemplary embodiments, it is to be understood that the invention is not limited to the disclosed exemplary embodiments. The scope of the following claims is to be accorded the broadest interpretation so as to encompass all such modifications and equivalent structures and functions.

This application claims the benefit of Japanese Patent Application No. 2006-251412, filed Sep. 15, 2006, which is hereby incorporated by reference herein in its entirety. 

1. An image encoding apparatus for encoding image data, comprising: a lossless encoding processing unit adapted to lossless-encode the image data for respective tiles each having a pre-set size; a determination unit adapted to determine for each tile based on a feature amount and attribute of image data in the tile of interest if the tile of interest is to be lossless-encoded or lossy-encoded, and to generate lossless/lossy determination information; a storage unit adapted to temporarily store the lossless-encoded data of the tile generated by said lossless encoding processing unit and the lossless/lossy determination information of said determination unit in association with each other; a lossy encoding processing unit adapted to decode the lossless-encoded data of a tile having lossy determination information in the encoded data stored in said storage unit and to lossy-encode the decoded data; an output unit adapted to output the lossy-encoded data generated by said lossy encoding processing unit and the lossless-encoded data having lossless determination information as encoded data of the image data to be encoded; and a control unit adapted to control said lossless encoding processing unit and said lossy encoding processing unit, wherein said lossy encoding processing unit comprises: a decoding unit adapted to decode the lossless-encoded data; a lossy encoding unit adapted to lossy-encode the decoded image data; a resolution converting unit adapted to convert the decoded image data into image data having a resolution lower than a resolution of the decoded image data; and a lossless encoding unit adapted to lossless-encode the image data converted by said resolution converting unit, wherein said control unit comprises: a first replacing unit adapted to control said decoding unit, said resolution converting unit, and said lossless encoding unit to replace the lossless-encoded data having the lossy determination information stored in said storage unit by lossless-encoded data of a lower resolution, every time the number of tiles, which is determined by said determination unit to be lossy-encoded, exceeds one of a plurality of different thresholds; and a second replacing unit adapted to control said decoding unit and said lossy encoding unit to replace the lossless-encoded data having the lossy determination information stored in said storage unit by lossy-encoded data upon completion of lossless encoding for one page by said lossless encoding processing unit.
 2. The apparatus according to claim 1, wherein said resolution converting unit executes conversion that halves the numbers of pixels of image data in horizontal and vertical directions, and letting N be the number of tiles that said lossy encoding processing unit can lossy-encode image data, which do not undergo the resolution conversion, within a time period required for said lossless encoding processing unit to execute lossless encoding processing of image data for one page, the plurality of thresholds are N×2^(i) (i=0, 1, 2, . . . ).
 3. A method of controlling an image encoding apparatus which comprises a storage unit that temporarily stores data during an encoding process, and encodes image data, comprising: a lossless encoding processing step, performed by a processor of lossless-encoding the image data for respective tiles each having a pre-set size; a determination step of determining for each tile based on a feature amount and attribute of image data in the tile of interest if the tile of interest is to be lossless-encoded or lossy-encoded, and generating lossless/lossy determination information; a storage step of temporarily storing, in the storage unit, the lossless-encoded data of the tile generated in the lossless encoding processing step and the lossless/lossy determination information of the determination step in association with each other; a lossy encoding processing step of decoding the lossless-encoded data of a tile having lossy determination information in the encoded data stored in the storage unit, and lossy-encoding the decoded data; an output step of outputting the lossy-encoded data generated in the lossy encoding processing step and the lossless-encoded data having lossless determination information as encoded data of the image data to be encoded; and a control step of controlling the lossless encoding processing step and the lossy encoding processing step, wherein the lossy encoding processing step comprises: a decoding step of decoding the lossless-encoded data; a lossy encoding step of lossy-encoding the decoded image data; a resolution converting step of converting the decoded image data into image data having a resolution lower than a resolution of the decoded image data; and a lossless encoding step of lossless-encoding the image data converted in the resolution converting step, wherein the control step comprises: a first replacing step of controlling the decoding step, the resolution converting step, and the lossless encoding step to replace the lossless-encoded data having the lossy determination information stored in the storage unit by lossless-encoded data of a lower resolution, every time the number of tiles, which is determined in the determination step to be lossy-encoded, exceeds one of a plurality of different thresholds; and a second replacing step of controlling the decoding step and the lossy encoding step to replace the lossless-encoded data having the lossy determination information stored in the storage unit by lossy-encoded data upon completion of lossless encoding for one page in the lossless encoding processing step.
 4. An image encoding apparatus for encoding image data, comprising: a lossless encoding processing unit adapted to input the image data for each tile having a pre-set size, to generate image data of a plurality of resolutions from the image data of the tile of interest, and to lossless-encode the image data of the respective resolutions; a determination unit adapted to determine for each tile based on a feature amount and attribute of image data in the tile of interest if the tile of interest is to be lossless-encoded or lossy-encoded, to generate lossless/lossy determination information, and to count the number of tiles which are determined to be lossy-encoded; a storage unit adapted to temporarily store the lossless-encoded data of the respective resolutions generated by said lossless encoding processing unit and the lossless/lossy determination information of said determination unit in association with each other; a lossy encoding processing unit adapted to decode the lossless-encoded data of each tile having lossy determination information of the encoded data stored in said storage unit and to lossy-encode the decoded data after completion of lossless encoding of image data for one page by said lossless encoding processing unit; an output unit adapted to output the lossy-encoded data generated by said lossy encoding processing unit and the lossless-encoded data having lossless determination information as encoded data of the image data; and a control unit adapted to set lossless-encoded data of each tile, which has a resolution depending on the number of tiles counted by said determination unit and has the lossy determination information stored in said storage unit, as data to be lossy-encoded by said lossy encoding processing unit.
 5. The apparatus according to claim 4, wherein said lossless encoding processing unit divides input image data into tiles each having a W×H pixel size, applies resolution conversion to each tile to generate a plurality of W/2^(i)×H/2^(i) (i=1, 2, . . . ) types of reduced-scale tiles, and lossless-encodes the original tile and the reduced-scale tiles to generate the lossless-encoded data of the plurality of resolutions for one tile, and letting N be the number of tiles that said lossy encoding processing unit can lossy-encode image data without resolution conversion within a time period required for said lossless encoding processing unit to execute lossless encoding processing of image data for one page, the plurality of thresholds are N×2^(i) (i=0, 1, 2, . . . ).
 6. The apparatus according to claim 4, wherein said control unit controls said lossless encoding processing unit to store only lossless-encoded data of a maximum resolution in said storage unit for tiles which are determined by said determination unit to be lossless-encoded during lossless encoding processing of image data for one page by said lossless encoding processing unit, said control unit inhibits, in turn in descending order of resolution, the lossless-encoded data of the plurality of resolutions from being stored in said storage unit for tiles which are determined by said determination unit to be lossy-encoded, every time the number of tiles counted by said determination unit exceeds one of the thresholds, during the lossless encoding processing of image data for one page by said lossless encoding processing unit, said control unit deletes, in turn in descending order of resolution, the lossless-encoded data which are already stored in said storage unit and are determined to be lossy-encoded, every time the number of tiles counted by said determination unit exceeds one of the thresholds, during the lossless encoding processing of image data for one page by said lossless encoding processing unit, and said control unit sets, as data which are to undergo lossy encoding processing of said lossy encoding processing unit, said only the lossless-encoded data of the maximum resolution, which remain stored in said storage unit and are associated with the lossy determination information, at a completion timing of the lossless encoding processing of image data for one page by said lossless encoding processing unit.
 7. The apparatus according to claim 4, further comprising a counting unit adapted to count code sizes for respective resolutions of tiles, which are determined by said determination unit to be lossless-encoded, of the lossless-encoded data generated by said lossless encoding processing unit, wherein said control unit comprises: a setting unit adapted to decide a resolution to be lossy-encoded based on the number of tiles counted by said determination unit upon completion of the lossless encoding processing of image data for one page by said lossless encoding processing unit, and to set the lossless-encoded image data, which have the decided resolution and are stored in association with the lossy determination information, as data to be processed by said lossy encoding processing unit; and a deciding unit adapted to decide a resolution of the lossless-encoded data to be output by said output unit based on a total size of lossy-encoded data generated by said lossy encoding processing unit according to the setting of said setting unit, a pre-set target code size, and the code sizes for the respective resolutions counted by said counting unit.
 8. A method of controlling an image encoding apparatus which comprises a storage unit that temporarily stores data during an encoding process, and encodes image data, comprising: a lossless encoding processing step, performed by a processor, of inputting the image data for each tile having a pre-set size, generating image data of a plurality of resolutions from the image data of the tile of interest, and lossless-encoding the image data of the respective resolutions; a determination step of determining for each tile based on a feature amount and attribute of image data in the tile of interest if the tile of interest is to be lossless-encoded or lossy-encoded, generating lossless/lossy determination information, and counting the number of tiles which are determined to be lossy-encoded; a storage step of temporarily storing, in the storage unit, the lossless-encoded data of the respective resolutions generated in the lossless encoding processing step and the lossless/lossy determination information of the determination step in association with each other; a lossy encoding processing step of decoding the lossless-encoded data of each tile having lossy determination information of the encoded data stored in the storage unit and lossy-encoding the decoded data after completion of lossless encoding of image data for one page in the lossless encoding processing step; an output step of outputting the lossy-encoded data generated in the lossy encoding processing step and the lossless-encoded data having lossless determination information as encoded data of the image data; and a control step of setting lossless-encoded data of each tile, which has a resolution depending on the number of tiles counted in the determination step and has the lossy determination information stored in the storage unit, as data to be lossy-encoded in the lossy encoding processing step.
 9. The method according to claim 8, wherein the lossless encoding processing step divides input image data into tiles each having a W×H pixel size, applies resolution conversion to each tile to generate a plurality of W/2^(i)×H/2^(i) (i=1, 2, . . . ) types of reduced-scale tiles, and lossless-encodes the original tile and the reduced-scale tiles to generate the lossless-encoded data of the plurality of resolutions for one tile, and letting N be the number of tiles that image data without resolution conversion can be lossy-encoded in the lossy encoding processing step within a time period required for the lossless encoding processing step to execute lossless encoding processing of image data for one page, the plurality of thresholds are N×2^(i) (i=0, 1, 2, . . . ).
 10. The method according to claim 8, wherein the control step controls the lossless encoding processing step to store only lossless-encoded data of a maximum resolution in the storage unit for tiles which are determined in the determination step to be lossless-encoded during lossless encoding processing of image data for one page in the lossless encoding processing step, the control step inhibits, in turn in descending order of resolution, the lossless-encoded data of the plurality of resolutions from being stored in the storage unit for tiles which are determined in the determination step to be lossy-encoded, every time the number of tiles counted in the determination step exceeds one of the thresholds, during the lossless encoding processing of image data for one page in the lossless encoding processing step, the control step deletes, in turn in descending order of resolution, the lossless-encoded data which are already stored in the storage unit and are determined to be lossy-encoded, every time the number of tiles counted in the determination step exceeds one of the thresholds, during the lossless encoding processing of image data for one page in the lossless encoding processing step, and the control step sets, as data which are to undergo lossy encoding processing of the lossy encoding processing step, the only the lossless-encoded data of the maximum resolution, which remain stored in the storage unit and are associated with the lossy determination information, at a completion timing of the lossless encoding processing of image data for one page in the lossless encoding processing step.
 11. The method according to claim 8, further comprising a counting step of counting code sizes for respective resolutions of tiles, which are determined in the determination step to be lossless-encoded, of the lossless-encoded data generated in the lossless encoding processing step, wherein the control step comprises: a setting step of deciding a resolution to be lossy-encoded based on the number of tiles counted in the determination step upon completion of the lossless encoding processing of image data for one page in the lossless encoding processing step, and setting the lossless-encoded image data, which have the decided resolution and are stored in association with the lossy determination information, as data to be processed in the lossy encoding processing step; and a deciding step of deciding a resolution of the lossless-encoded data to be output in the output step based on a total size of lossy-encoded data generated in the lossy encoding processing step according to the setting of the setting step, a pre-set target code size, and the code sizes for the respective resolutions counted in the counting step. 